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

177
Vistas
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
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