Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!