question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Component is not being re-rendered on state change

See original GitHub issue

I’m setting errors state on catch block but this is not causing component re-render.

schema.validate(validation).catch(err => {
  errors.merge({name: "error"})
})

I expected the component re-render but it didn’t. To cause re-render, currently I’m doing a trick by getting state first:

schema.validate(validation).catch(err => {
  errors.get() // now, this cause re-render
  errors.merge({name: "error"})
})

Why so? I also tried set method instead of merge but still not getting expected result. Note: The issue persist only for the first time. On next time catch, the component re-renders as expected.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
avkonstcommented, Sep 7, 2021

fixed in 3.0.10

1reaction
avkonstcommented, Sep 7, 2021

and it is only an issue if the field is undefined on the initial render

Read more comments on GitHub >

github_iconTop Results From Across the Web

React component not re-rendering on state change
In my weird scenario my component was being rendered inside the state and therefore couldn't be updated. Below is a simple example:
Read more >
How and when to force a React component to re-render
The component did not change, so there was no re-rendering trigger. Here's why. React evaluates state changes by checking its shallow ...
Read more >
Components not re-rendering with state changes : r/react
The thing is since React only evaluates states in a shallow way, changing key2's value will not cause a rerender because React will...
Read more >
When does React re-render components?
State changes in your application will be applied to the VDOM first. If the new state of the VDOM requires a UI change,...
Read more >
Re-rendering Components in ReactJS
A simple update of the state, from anywhere in the code, causes all the User Interface (UI) elements to be re-rendered automatically.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found