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

176
Views
How to render input fields based on selection after a DB query (Reactjs)?

What I'm trying to do here is load the page with an input that can be selected or unselected and the value will be predefined from a database check. So I visit the database before the render is done and I return a true/false but whenever the true is selected I can see that the page loads before applying the changes I required. So if a button was supposed to be disabled then it would first load as it is and then the disabling would follow. So is there a way to ensure that the render method waits on my changes or is it just the logic? I'm confused.

This here is one instance, I have 3 currently in my code..

// added this variable to state

this.state = {
        verificationStatus: ''
    }

// getStatus function

    await Http.post({
        url: '/api/id-status-check',
        headers: {'user': localStorage.getItem('userId')}
    })
        .then((response)=>{
            verificationStatus = response.identificationStatus

            this.setState({verificationStatus: response.identificationStatus})

Then I'm trying to do something like this but the class is only removed after the page loads.

            if (this.state.verificationStatus.toLowerCase() !== 'failed') {
                dCheck.disabled = true
                dCheck.classList.remove('btn-primary2')

This is my componentDidMount function where I attempt to run the same function to get the status before the initial render. And btw the logic works to produce the output but only after the page loads so I can see the button color change on load which is my concern.

componentDidMount() {
    this.getStatus().then(r => {})
}
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!