cssinjs / jss

JSS is an authoring tool for CSS which uses JavaScript as a host language.
https://cssinjs.org
MIT License
7.07k stars 399 forks source link

[react-jss] theme prop without styled themes #856

Closed HenriBeck closed 5 years ago

HenriBeck commented 6 years ago

Is your feature request related to a problem? Please describe. Get the theme as a prop even if the styles aren't themed.

Describe the solution you'd like We either allow for an option like withTheme or always subscribe to theme updates and pass the theme, though this solution would require some investigation if it creates performance issues.

Initially created in cssinjs/react-jss#291

HenriBeck commented 6 years ago

@kof and I decided that we will implement this feature by simply only passing the theme down to the component when it's inside the `inject´ sheet. We will subscribe to the theme when the styles are themed, or the theme is explicitly passed down.

kof commented 6 years ago

@HenriBeck means when "inject" option contains "theme": e.g. injectSheet(styles, {inject: ['classes', 'theme']}).

Also we discussed that we should turn off theme passing to the child component by default. I couldn't recall why I decided to pass the theme by default to the child anyways. If we find that out we could rethink. Right now I don't know why child component needs to be aware of the theme over props without explicitly asking for that.

HenriBeck commented 5 years ago

Implemented in #934