preact-compat icon indicating copy to clipboard operation
preact-compat copied to clipboard

Components not getting updates via context from JSS/ThemeProvider

Open gusgid opened this issue 7 years ago • 3 comments

The following example shows how the theme is correctly toggled using React and React-dom. Switching to react-compat breaks it. Something todo with context being used by ThemeProvider?

https://stackblitz.com/edit/react-vxvdmr

What we found:

  • CSS selectors is changed in the header as expected
  • React Component do re-render as expected
  • The classes object sent via Context from ThemeProvider is not updated (rerender with the original classNames that does not have a definition anymore)

!! Our example offline at least renders using preact-compat with the default theme, but at stackblitz it stops as soon we try to mount a component that is wrapped by injectSheet hoc.

gusgid avatar Feb 16 '18 09:02 gusgid

Hmm - have you tried this outside Stackblitz? I don't see any aliases defined there, so when react-redux or react-jss import react, they're still getting React proper (not compat). That's definitely going to break things, it's never a good idea to run preact-compat and react on the same vtree.

developit avatar Feb 23 '18 16:02 developit

Hi, ahh yes, the issue was first found in local project with aliases setup in webpack:

resolve: { alias: { react: "preact-compat", "react-dom": "preact-compat" ...

Then it at leasts runs without errors. Do you want me to setup a repo with it all?

gusgid avatar Feb 26 '18 09:02 gusgid

If you have the time, otherwise it's pretty hard to tell what's going on.

developit avatar May 25 '18 18:05 developit