Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[react-jss] Remove inject option #934

Merged
merged 19 commits into from
Dec 20, 2018

Conversation

HenriBeck
Copy link
Member

What would you like to add/fix?
This removes the inject option for the HOC and replaces it with only one option for injecting the theme.

Injecting the sheet shouldn't be necessary and unstable because it would be sometimes the dynamic sheet if it exists or the static sheet.
And there is no real benefit to not injecting the classes prop.

Injecting the theme is now handled by the option injectTheme which is a boolean.

@HenriBeck HenriBeck requested review from kof and removed request for kof December 11, 2018 14:35

if (injectMap.sheet && !props.sheet && sheet) props.sheet = sheet
if (injectMap.theme) props.theme = theme
if (injectTheme && props.theme) props.theme = theme
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we even need injectTheme prop

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always inject theme?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually always injecting theme shouldn't be a big problem, the theme shouldn't change often that it would cause a lot of rerenders

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say yes, btw that line doesn't make sense, bc you have no theme in props, props is the rest ... so we seem to lack a test for this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a test for that, the tests are failing anyway right now

@HenriBeck HenriBeck requested a review from kof December 13, 2018 12:25
@@ -25,7 +25,7 @@ export const JssProvider: React.ComponentType<{
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>
type Options = {
index?: number
inject?: Array<'classes' | 'theme' | 'sheet'>
injectTheme?: boolean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we can remove injectTheme completely?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, someone might still want to subscribe to the theme even though he has a styles object

@@ -76,8 +60,7 @@ export default function createHOC<
options: Options
): ComponentType<OuterPropsType> {
const isThemingEnabled = typeof stylesOrCreator === 'function'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can also get rid of isThemingEnabled, because if a theme is on the context, its weird it would be implicitely depending on styles being a function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we still need to do some checks based on isThemingEnabled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets revisit them, I think we can get rid of it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need this to decide which theme we are using.

When someone passed a function as the styles, we use the theme prop.

Because the user still might pass injectTheme: true which would subscribe to the theme, even though the styles are not theme dependent, we would create additional stylesheets.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think isThemingEnabled logic needs to be different, e.g. shouldSubscribeTheme = options.injectTheme || stylesIsfunction and rendering of styles just based on stylesIsFunction

@HenriBeck HenriBeck merged commit 6d3c5ba into react-jss/update Dec 20, 2018
@HenriBeck HenriBeck deleted the react-jss/remove-inject-option branch December 20, 2018 15:39
kof added a commit that referenced this pull request Jan 16, 2019
* [WIP] Update to new react context for the jss context (#924)

* Update to new react context for the jss context

* Fixed types

* Fix some tests

* Remove unnecessary cloning

* Fix JssProvider

* Update logic of merging context

* Fix a few issues and tests

* Make getTheme non public

* Update warning inside JssProvider

* Remove duplicate beforeEach

* Update size-snapshot

* Fix a few bugs

* Created a Managers type

* Create sheetOptions prop type definition

* Removed meta property from sheet options shape

* Fix creating a new generateId for every render

* Move media into it's own prop

* Added changelog

* Rename to JssContextSubscriber

* Moved context to jssContext prop instead of spreading it

* [react-jss] Remove inject option (#934)

* Update to new react context for the jss context

* Fixed types

* Fix some tests

* Remove unnecessary cloning

* Fix JssProvider

* Update logic of merging context

* Fix a few issues and tests

* Make getTheme non public

* Update warning inside JssProvider

* Remove duplicate beforeEach

* Update size-snapshot

* Fix a few bugs

* Remove inject option

* Fix

* Always inject the theme

* Only inject theme when injectTheme is true

* Upgrade theming package (#942)

* Add forwardRef support (#943)

* [react-jss] Merge classes instead of overwriting (#946)

* Add forwardRef support

* Add support for merging the classes

* Fix path of test file

* Remove jsdoc comment

* Implement custom memoize-one

* Convert function to arrow function

* Fix

* Update some of the tests

* Update dynamic styles tests

* Fix SSR tests

* Add theme inject tests

* Add merge classes tests

* Remove dependency of react-dom

* Fix an issue with memoizing and memoize the context

* Remove createHoC file and remove injectSheet to withStyles

* Update TS types

* Update TS types

* Fix flow types

* Fix react-jss types

* Rename injectSheet to withStyles in docs

* Fix react-jss types

* Update changelog.md

* Rename class and

* Fix tests

* Fix a few typos in docs

* Fix changelog

* Use javascript for codeblocks instead of js

* Upgrade theming

* Fix type import

* Update size-snapshot

* Fix docs

* Update size-snapshot

* Upgrade theming to v3.0.2

* Use travis_wait for test command

* Remove travis_wait command

* Update docs
bhupinderbola pushed a commit to bhupinderbola/jss that referenced this pull request Sep 17, 2019
* [WIP] Update to new react context for the jss context (cssinjs#924)

* Update to new react context for the jss context

* Fixed types

* Fix some tests

* Remove unnecessary cloning

* Fix JssProvider

* Update logic of merging context

* Fix a few issues and tests

* Make getTheme non public

* Update warning inside JssProvider

* Remove duplicate beforeEach

* Update size-snapshot

* Fix a few bugs

* Created a Managers type

* Create sheetOptions prop type definition

* Removed meta property from sheet options shape

* Fix creating a new generateId for every render

* Move media into it's own prop

* Added changelog

* Rename to JssContextSubscriber

* Moved context to jssContext prop instead of spreading it

* [react-jss] Remove inject option (cssinjs#934)

* Update to new react context for the jss context

* Fixed types

* Fix some tests

* Remove unnecessary cloning

* Fix JssProvider

* Update logic of merging context

* Fix a few issues and tests

* Make getTheme non public

* Update warning inside JssProvider

* Remove duplicate beforeEach

* Update size-snapshot

* Fix a few bugs

* Remove inject option

* Fix

* Always inject the theme

* Only inject theme when injectTheme is true

* Upgrade theming package (cssinjs#942)

* Add forwardRef support (cssinjs#943)

* [react-jss] Merge classes instead of overwriting (cssinjs#946)

* Add forwardRef support

* Add support for merging the classes

* Fix path of test file

* Remove jsdoc comment

* Implement custom memoize-one

* Convert function to arrow function

* Fix

* Update some of the tests

* Update dynamic styles tests

* Fix SSR tests

* Add theme inject tests

* Add merge classes tests

* Remove dependency of react-dom

* Fix an issue with memoizing and memoize the context

* Remove createHoC file and remove injectSheet to withStyles

* Update TS types

* Update TS types

* Fix flow types

* Fix react-jss types

* Rename injectSheet to withStyles in docs

* Fix react-jss types

* Update changelog.md

* Rename class and

* Fix tests

* Fix a few typos in docs

* Fix changelog

* Use javascript for codeblocks instead of js

* Upgrade theming

* Fix type import

* Update size-snapshot

* Fix docs

* Update size-snapshot

* Upgrade theming to v3.0.2

* Use travis_wait for test command

* Remove travis_wait command

* Update docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants