Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

448
Visualizações
How to export state variable of react.js?

How to export state variable of react.js? means we have a state variable in react.js and this state variable needs to be in another component then how to we export that component.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Just declare your state, import the Component which you want to send the state variable and then pass it as attribute/parameter. Something is this:

import Data from './data';
import React, { Component } from "react";
import { connect } from "react-redux";
class Test extends Component {
    this.state = {
                firstName: "",
                lastName: "",
                dateOfBirth: "",
                emailAddress: "",
                fatherFirstName: "",
                fatherLastName: ""
            }

    componentDidMount() {
            this.props.setValues();
        }

    setValues= async () => {
            this.setState({
                firstName: "Teddy",
                lastName: "Bear",
                dateOfBirth: 2000-12-07,
                emailAddress: "teddybear@gmail.com",
                fatherFirstName: "Jonhathan",
                fatherLastName: "Bear"
            })
        }
render(){
return(
     <Container>
         <Data
             data={this.state}
         />
     </Container>
    )
   }

}
export default Test;

This is how it is done; how state variables are sent from one component to another component. You just need to send it as a parameter in a function. And this data sent in Data is used as this.props.

https://reactjs.org/ this site all you can start with and you can refer to this whenevr possible. I hope this simple interpretation will atleast tell you how it is done

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda