Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
Export Variable to use in other classes in ReactJS

A small application that manages and displays users should have the possibility to change the data using "CRUD". However, I have to export the variable u.userID.

Given the class "UserManagementPage"

class UserManagementPage extends Component {

    constructor(props) {
        super(props);
        this.state = {userList: []}
    }

    getUsersData() {

        const hash="whatever"
        const requestOptions = {
            method: 'GET',
            headers: {  'Authorization': `Basic ${hash}` },
            
            };
        axios
            .get('https://localhost:443/user/', requestOptions)
            .then(res => {
                const data = res.data
                console.log(data)
                
                const users = data.map(u =>
                    <div>
                    <p>{u.userID}
                    
                     </p>
                    
                    
                    </div>
                    )

                    this.setState({
                        users
                    })

            })
            .catch((error) => {
                console.log(error)
            })

    }

    componentDidMount(){
        this.getUsersData()
    }

export default UserManagementPage

How do I export u.userID so that I can reuse it in other classes?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda