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.

[ColorModeProvider] Does not re-render when value prop changes

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mattjenningscommented, Apr 15, 2020

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 custom ColorModeProvider workaround. I do wonder if those issues may be symptoms of this issue.

0reactions
segunadebayocommented, Apr 15, 2020

Let me know if you need any further help and I’ll reopen this.

We’ll also consider syncing the value prop of ColorModeProvider with state so this usage works. Thinking about @bear-in-a-box comment on electron.

Read more comments on GitHub >

github_iconTop 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 >

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