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

That is my condition

constructor(props: ListProps) {
    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(() => {
    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 (}
            renderItem={({ item }) => (
            )} />


This is the edit file:

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

const EditarColaborador = (props)=>{

                Editar Colaborador


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 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();


            const user=await firebase.auth().currentUser;


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 {

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

   const uploadImage= async(uri, nameImage)=>{
    setTextLoading=("actualizando avatar");
       const response =await fetch(uri);
       const blob = await response.blob();  
       const ref = firebase
       return ref.put(blob);


   const updatePhotoUrl = uid =>{
       .then(async result =>{
        const update ={
        await firebase.auth().currentUser.updateProfile(update);
       }).catch(()=>{'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)



(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:


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

With Flamelink the scheme looks like this:



My native response code is below:

const user = navigation.getParam("user");
     const currentUserData = await firebase

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:

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) {
        score: score + 1,
        numOfQuestions: numOfQuestions + 1
    } else {
        numOfQuestions: numOfQuestions + 1

    if (numOfQuestions === quizzes(currentQuiz).questions.length - 1) {
        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) {
        resultSummary: false,
        numOfQuestions: 0,
        score: 0,
        currentQuiz: 0
    } else {
        resultSummary: false,
        numOfQuestions: 0,
        score: 0,
        currentQuiz: currentQuiz + 1

  render() {
    const {
    } = this.state;

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

    const shuffledAnswerChoices = shuffle((

    return (


{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.


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


    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 {
    } from './styles';

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


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;


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