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

141
Visualizações
How does redux decide when to update the UI?

By design when the state updates the UI should update.

However. If I return a brand new object, it will not update the UI.

  case 'clearArticleForm':
    let newState1 = {};
    return newState1;
  }

If I return a brand new object and populate it as follows I still can not get the UI to update.

const initial_state = {link:{}, image:{}, title:{}, summary:{}, tag:{}, domain:{}, valid: false};


  case 'clearArticleForm':
    let newState1 = initial_state;
    return newState1;
  }

However if I populate it this way, I will finally get the UI to update.

const initial_state = {link:{value:''}, image:{value:''}, title:{value:''}, summary:{value:''}, tag:{value:''}, domain:{value:''}, valid: false};

  case 'clearArticleForm':
    let newState1 = initial_state;
    return newState1;
  }

I though that by definition / design when the state changes the UI should update. What is going on here.

The state changes as I verified in the functional component however the UI does not until the 3rd example.

I have described the behavior for this case however I am looking for a rule and documentation so I understand the general case: induction.

Functional Component:

const data = useSelector((state) => state.ArticleForm) || {};

// ... snip

<M10 valid = {data.link.valid}     value = {data.link.value}    onChange={onChange} className = 'modal_article_input' placeholder="link"    name="link" />
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Although the state is updating, that state must actually be used in your returned JSX

For example, if you are watching a part of the state tree in your functional component but do not use that part of the tree in your component, that UI will not update.

about 4 years ago · Juan Pablo Isaza Relatório

0

In your middle code snippet your state has keys and their values are empty objects.

const initial_state = {link:{}, image:{}, title:{}, summary:{}, tag:{}, domain:{}, valid: false};

but in the last one these objects has keys and values.

const initial_state = {link:{value:''}, image:{value:''}, title:{value:''}, summary:{value:''}, tag:{value:''}, domain:{value:''}, valid: false};

can this be the reason for not updating the render?

about 4 years ago · Juan Pablo Isaza Relatório
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