mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 00:20:04 +01:00
[DevTools] Rerender when the browser theme changes (#33992)
When the browser theme changes, we don't immediately rerender the UI so we don't pick up the new theme if the React devtools are set to auto. This picks up the change immediately.
This commit is contained in:
parent
142fd27bf6
commit
b1a6f03f8a
|
|
@ -530,3 +530,16 @@ if (__IS_FIREFOX__) {
|
|||
connectExtensionPort();
|
||||
|
||||
mountReactDevToolsWhenReactHasLoaded();
|
||||
|
||||
function onThemeChanged(themeName) {
|
||||
// Rerender with the new theme
|
||||
render();
|
||||
}
|
||||
|
||||
if (chrome.devtools.panels.setThemeChangeHandler) {
|
||||
// Chrome
|
||||
chrome.devtools.panels.setThemeChangeHandler(onThemeChanged);
|
||||
} else if (chrome.devtools.panels.onThemeChanged) {
|
||||
// Firefox
|
||||
chrome.devtools.panels.onThemeChanged.addListener(onThemeChanged);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user