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

178
Visualizações
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 à 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