Why theme change doesn't propagate to the child?
See original GitHub issueIn the following example, when the theme selector changes to “product”, the Button is rerendered but it still sees the “marketing” theme. What am I missing here?
function Button({ primary, children }) {
return (
<button
sx={{
bg: primary ? "primary" : "secondary"
}}
>
{children}
</button>
);
}
function App() {
const [theme, setTheme] = useState("marketing");
return (
<ThemeProvider theme={require(`./themes/${theme}`)}>
<select
value={theme}
onChange={e => {
setTheme(e.target.value);
}}
>
<option value="marketing">Marketing</option>
<option value="product">Product</option>
</select>
<Button primary>Do something</Button>
</ThemeProvider>
);
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Why doesn't border-color propagate to child elements?
It's because you're specifying that a specific div (ie content) gets that particular pattern. You could change ...
Read more >Child Theme not updating Parent Theme, please help
Hi Dominic, Yep I've activated child theme and I've been adding css to sections when customising the child theme, such as adding buttons...
Read more >How to Create a WordPress Child Theme: A Step-by-Step Guide
Creating a child theme allows you to modify the parent theme without losing your customizations. Without a child theme, you'd have to modify...
Read more >Why doesn't RegSetKeySecurity propagate inheritable ACEs ...
Under the new model, when you change the parent ACL, the security attributes of all child objects are automatically recalculated, and it is...
Read more >What Is a WordPress Child Theme? Pros, Cons, and More
You can then customize the child theme without making any changes to ... of selecting a parent theme that doesn't offer much functionality....
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
@moroshko we’ve updated the behavior here a little bit. If you not using
gatsby-plugin-theme-ui
and using theThemeProvider
directly for this, I think the theme should be able to update in a setup like this. Could you try with the latest version to see if this is still an issue?Closing this because the behavior will be changing in v0.3 – see #535