Component is not being re-rendered on state change
See original GitHub issueI’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:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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