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.

Why theme change doesn't propagate to the child?

See original GitHub issue

In 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?

CodeSandbox

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:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jxnblkcommented, Sep 17, 2019

@moroshko we’ve updated the behavior here a little bit. If you not using gatsby-plugin-theme-ui and using the ThemeProvider 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?

0reactions
jxnblkcommented, Jan 2, 2020

Closing this because the behavior will be changing in v0.3 – see #535

Read more comments on GitHub >

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

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