-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<Admin /> "theme" prop no longer updates/refreshes if providing a different "theme" conditionally. #8022
Comments
Thanks for your report, I could reproduce the bug |
Note that if you want to change the theme programmatically, instead of doing it from outside react-admin, you can use the https://marmelab.com/react-admin/Theming.html#changing-the-theme-programmatically |
You should note the bug fix on your sandbox using the react-admin 4.2.7. Consequently, I'll close the issue. |
Well I just tried updating to react-admin 4.2.7 but the button didn't change from green to yellow. Don't know if I missed something |
Your CodeSandbox shows the right behavior with 4.2.7, so I think this is fixed. |
What you were expecting:
In react-admin V3, I was able to update the theme conditionally and it was updating when rerendering.
What happened instead:
Now in react-admin V4
<Admin theme={theme} />
only keeps the first instance oftheme
, discarding other instances when rerendering.Steps to reproduce:
setTimeout
the primary color is supposed to turn yellow but it doesn't with new React-Admin V4Temporary solution
Again, in V3 it was working directly with
<Admin theme={conditionalTheme} />
without effort. Now the only solution that I have is to separate<AdminContext />
and<AdminUI />
, then give a first theme instance to<AdminContext />
and then update the theme with my condition inside<AdminUI />
usinguseTheme
. And now it's working.The text was updated successfully, but these errors were encountered: