reactjs – How to create a React Class property with the Union type

That is my condition

constructor(props: ListProps) {
    super(props);
    this.state = {
      selectedItem: this.props.alreadySelected
        ? this.props.alreadySelected
        : {
            name: "Select Item"
          },
      isOpen: false,
      page: 0,
      itemsList: (),
      ready: false,
      loadMore: false,
      filter: "" // filter string
    };
  }

I need the itemsList array to support two types: "ProjectDtoImpl and IssueDtoImpl"

reagjs – Cleanup function when dismantling the component in the UseEffect of React

I have a project in React Made with React Hooks that calls a function that loads animation with js when the hero component of a page loads.

This function has a fixed interval. If I click on another page before the end of the interval (it is still running) and the page fails because it is of course not the start page and cannot find several ID elements.

How can I cancel or clean the function by disassembling the component with a reaction hook?

I leave the usage effect I have now, but that doesn't work, doesn't clean it.

  useEffect(() => {
    Animations.hero()
    return () => Animations.hero(); 

  }, (component,))

Javascript – How do I receive data in a React Native component?

Hello everybody! I'm studying React Native and encountered a problem that I couldn't solve. I tried all the options and searched in several places 🙁

I have a list of employees and each employee has an ID, a name, a position and a sector. The listing and deleting operations work, but I want to do the editing operation. For this I need the employee ID. I can't pass this ID on to the other screen to edit it.

This is the previous code:

return (

        item.id}
            renderItem={({ item }) => (
                
                    {item.nome}
                    {item.cargo}
                    
                        navigation.navigate('EditarColaboradores')}>
                            Editar
                        
                        excluiColaborador(item.id)}>
                            Excluir
                        
                    
                
            )} />

    )

This is the edit file:

import React, { useState, useEffect } from 'react';
import axios from 'axios';
import {
    View,
    Text
} from 'react-native';

const EditarColaborador = (props)=>{

    return(
        
            
                Editar Colaborador
            
            {
                console.log(props.id)
            }
        
    )

}

export default EditarColaborador

I found that writing a property called ID on the button and "retrieving" it in the "props" of the recipient file would solve the problem. but the value of props.id is "undefined"

I don't want to generate the load in React Native

Enter the image description here

This is the code of the registered text with which I send the text shop to infoUser to use it. I assign the text, but the load is not performed and a message is generated to indicate this
"setTextLoading" is read-only

  import Loading from "../../components/Loading";

export default function UserLogged() {
    const(userInfo, setUserInfo)=useState({});
    const(reloadData, setReloadData)=useState(false);
    const(isLoading, setIsLoading)=useState(false);
    const (textLoading, setTextLoading)=useState("");
    const toastRef=useRef();

    useEffect(()=>{

        (async()=>{
            const user=await firebase.auth().currentUser;
            setUserInfo(user.providerData(0))
        })();
        setReloadData(false);
    },(reloadData))

    return(
        
            
            

This is the class in which the load is sent to generate the message
and when I run the application on my mobile device
at the time of the profile change
It already generates the following error message and does not load me

Error: "setTextLoading" is read-only

and then this message

(Unwritten promise rejection: error: "setTextLoading" is read-only)

    import React from "react";
import {View, Text, StyleSheet} from "react-native";
import {Avatar} from "react-native-elements";
import * as firebase from "firebase";
import * as permissions from "expo-permissions";
import * as imagePicker from"expo-image-picker";


export default function InfoUser(props){
    const {
    userInfo:{uid,displayName,email,photoURL},
    setReloadData,
    toastRef,
    setIsLoading,
    setTextLoading
    }=props;
   console.log(props);

   const changeAvatar= async()=>{
    const resultPermission=  await permissions.askAsync(permissions.CAMERA_ROLL);
    const resultPermissionCamera=resultPermission.permissions.cameraRoll.status;    
       if(resultPermissionCamera==="denied"){
        toastRef.current.show("se necesitan aceptar los permisos de la galeria ");
    } else {
        const result= await  imagePicker.launchImageLibraryAsync({
            allowsEditing:true,
            aspect:(4,3)
        })
        if(result.cancelled){
            toastRef.current.show("cerro la galeria de imagenes sin seleccionar ninguna imagen");
        }else{
            uploadImage(result.uri, uid).then(()=>{
                updatePhotoUrl(uid);
            })
        }
    }

   }
   const uploadImage= async(uri, nameImage)=>{
    setTextLoading=("actualizando avatar");
       setIsLoading(true);
       const response =await fetch(uri);
       const blob = await response.blob();  
       const ref = firebase
       .storage()
       .ref()
       .child(`avatar/${nameImage}`);
       return ref.put(blob);

   };

   const updatePhotoUrl = uid =>{
    firebase
       .storage()
       .ref(`avatar/${uid}`)
       .getDownloadURL()
       .then(async result =>{
        const update ={
            photoURL:result
        }
        await firebase.auth().currentUser.updateProfile(update);
        setReloadData(true);
        setIsLoading(false);
       }).catch(()=>{
        toastRef.current.show('Error al obtener la foto de perfil');
       })

   }

(React Native) TypeError: undefined is not an object (evaluation of & # 39; _this.props.navigation & # 39;)

I cannot fix this error. someone is helping me

I click the button to go to another page and it appears. Follow the code:

(This is the code for the menu component. It contains a list of buttons with this structure.)

The same component has this structure.

const Menu = () => {...}

(Key structure)

            
                 this.props.navigation.navigate('Dashboard')}>
                    
                
            

`

(Router file) Of course there are more screens, I only inserted one, but the others are the same, then there is createSwitchNagivation and inside I call this stack and dps I give an export


const Stack = createStackNavigator({
Dashboard: {
screen: Dashboard,
navigationOptions: {
headerShown: false,
}
}
}

firebase – How can I assign content to certain logged in users in Flamelink and React Native?

I am using Firebase with React Native and have just started using Flamelink as a CMS.

Before using Flamelink, I was able to get certain content from a logged in user through a real-time Firebase database because the scheme was as follows:

**fruits**
mwaKRypUrNb8rJdsj9YUxw0sA892
-M055RlZ7HBzgRD9LS1d
-M055Why2psB2kqE4mYO
-M05W3LK8C1kgFsPNRqa
-M05W47cbhJ2VA_Y2nnT
-M05W5Wu9Pp6TZJJPc8t
-M05W6Xc_iP1upbyENpj
-M05W7JnVt3t3DsjNaRT
-M05W8OuZph-1gDDY9UX
-M05W9Fws0_hsNCAyKDt
**users**
-zFWGnGhEmbfhjAJsUT99ZbkJBZ33

As you can see, the fruit scheme had user-specific content.

With Flamelink the scheme looks like this:

**flamelink**
--environments
----production
------content
--------**fruitEntryForm**
----------en-US
------------1582070066847
------------1582074440836
------------1582080914427

**schemas**
**media**
**permissions**
**settings**
**users**
--zFWGnGhEmbfhjAJsUT99ZbkJBZ33

My native response code is below:

const user = navigation.getParam("user");
     const currentUserData = await firebase
      .database()
      .ref("flamelink/users")
      .child(user.uid)
      .once("value");

const fruits = await app.content.get("content");

How can I change Flamelink so that I can manage content based on the logged in user?

CSS – Using React, Quiz Implementation

I created a quiz app with React: https://codesandbox.io/s/eloquent-kare-gczfw

It would be great to get feedback, especially on the animation that occurs when you click the "Next" button. I noticed that the animation happens first, then not, then happens again. I wonder what I'm missing so that the animation always works the next time I click.

I have created an "animation" status field in the quiz component so that it changes from "false" to "true" and vice versa.

class Quiz extends React.Component {
  state = {
    currentQuiz: 0,
    numOfQuestions: 0,
    score: 0,
    resultSummary: false,
    animation: false
  };

  handleNextQuestion = answer => {
    const { currentQuiz, numOfQuestions, score } = this.state;

    if (answer) {
      this.setState({
        score: score + 1,
        numOfQuestions: numOfQuestions + 1
      });
    } else {
      this.setState({
        numOfQuestions: numOfQuestions + 1
      });
    }

    if (numOfQuestions === quizzes(currentQuiz).questions.length - 1) {
      this.setState({
        numOfQuestions,
        resultSummary: true
      });
    }

    if (!this.state.animation) {
      this.setState({ animation: "multiple-choices" });
    } else {
      this.setState({ animation: false });
    }
  };

  handleNextQuiz = () => {
    const { currentQuiz } = this.state;

    if (currentQuiz + 1 === quizzes.length) {
      this.setState({
        resultSummary: false,
        numOfQuestions: 0,
        score: 0,
        currentQuiz: 0
      });
    } else {
      this.setState({
        resultSummary: false,
        numOfQuestions: 0,
        score: 0,
        currentQuiz: currentQuiz + 1
      });
    }
  };

  render() {
    const {
      currentQuiz,
      numOfQuestions,
      score,
      resultSummary,
      animation
    } = this.state;

    const { title, questions } = quizzes(currentQuiz);
    const currentQuestion = questions(numOfQuestions);

    const shuffledAnswerChoices = shuffle((
      ...currentQuestion.incorrectAnswers,
      currentQuestion.correctAnswer
    ));

    return (
      

{title}

{resultSummary ? ( ) : ( )}
); } } export default Quiz;

I also wonder if 1) there is a better way to manage status in this little app, and / or 2) tips on media queries for mobile devices (I'm a bit new to responsive design).

Development environment Python Flask, react with node and webpack and load it into a Docker container during operation

Is there a general guideline I could follow to set up a Python bottle development environment, node.js – webpack – react.js, in a Docker container that supports hot reload?

I followed a few instructions online, but couldn't set up a working environment because I want it to work.

Ideally, every change in the piston back end and in the reaction front end triggers a reload of the component and reflects the changes. All of this is in a Docker container that can be started with docker-compose. The best way to build a production build is with a separate command to deploy the app to a production environment from within the Docker container.

I am not choosing a ready-made solution from one of you, but a policy that should be followed. I also wonder how to structure the project in relation to the folder tree.

I am grateful for any information in any direction.

chears,
Patrick

css – Align Navbar Bootstrap React

I try to align the navigation bar to the right, but it looks like this today without success:

Insert picture description here

index.js

    import React, { Component } from 'react';
    import 'bootstrap/dist/css/bootstrap.min.css';
    import { Nav, Navbar } from 'react-bootstrap';

    import Nav_Link from '../../components/index';
    import LogoImg from '../../assets/logo.png';
    import RetanguloImg from '../../assets/retangulo.png';
    import PredioImg from '../../assets/predio.png';
    import {
      Nav_Link_Line,
      Button,
      Title,
      Text,
      Text2,
      Button2,
      Table,
    } from './styles';

    export default class Main extends Component {
      render() {
        return (
          

styles.js

export const Nav_Link = styled.a`
  margin-left: 31px;
  margin-top: 15px;
  color: white;
  display: flex !important;
  justify-content: end !important;

  &:link {
    text-decoration: none;
  }

  &:hover {
    color: #748aaa;
  }
`;

export const Nav_Link_Line = styled.text`
      margin-left: 31px;
      margin-top: 10px;
      color: white;
    `;

global.js

.navbar {
    background-color: #3D5975;
    color: #ffff;
    font-weight: bold;
    height: 64px;
    width: 100%;
  }