[ColorModeProvider] Does not re-render when value prop changes
See original GitHub issueDescribe the bug
If you choose to manually provide the color mode value to ColorModeProvider, it does not re-render when the value
prop changes
Expected Behavior It should rerender child components with the new color mode
To Reproduce https://codesandbox.io/s/chakra-ui-color-mode-bug-xfzv9
A temporary workaround is to also add a key
prop of the color mode value, but this unmounts all children when it changes, so it’s not ideal.
Desktop (please complete the following information):
- OS: macOS
- Browser: chrome
- Version: 81
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
React: why child component doesn't update when prop changes
Update the child to have the attribute 'key' equal to the name. The component will re-render every time the key changes.
Read more >Why React Child Components Don't Update on Prop Changes
In React, it's a common problem to have child components that don't re-render when you expect them to. In particular, a common problems...
Read more >does a component rerender only when its props change, or ...
I've only ever used redux with hooks, not connect, however, with memo or usememo the parent component explicitly has to tell react which...
Read more >Re-rendering Components in ReactJS - GeeksforGeeks
Rendering components is not in user hands, it is a part of React Component ... re-render whenever there is a change in their...
Read more >5 Ways to Avoid React Component Re-Renderings
So, it will not re-render the component if the user clicks the same item again ... has a toggle that re-renders the component...
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 FreeTop 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
Top GitHub Comments
I see, I would still expect the
value
prop to change the state value, though. Syncing that value to the state would be the best solution.The reason I was providing the value myself was to workaround issues #305, #349, and #511. It worked properly when I did either the
key
prop or customColorModeProvider
workaround. I do wonder if those issues may be symptoms of this issue.Let me know if you need any further help and I’ll reopen this.
We’ll also consider syncing the
value
prop of ColorModeProvider withstate
so this usage works. Thinking about @bear-in-a-box comment on electron.