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

Use componentDidMount for WithStyles #1157

Merged
merged 8 commits into from
Jul 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@ Since you are interested in what happens next, in case, you work for a for-profi

---

### Bug fixes

- [react-jss] withStyles shouldn't attach() on SSR ([#1149](https://github.com/cssinjs/jss/pull/1149), [#1157](https://github.com/cssinjs/jss/pull/1157))

### Improvements

- [jss] Improve treeshaking for webpack by not using `global`. ([#1153](https://github.com/cssinjs/jss/pull/1153))
24 changes: 12 additions & 12 deletions packages/react-jss/.size-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"dist/react-jss.js": {
"bundled": 168372,
"minified": 58132,
"gzipped": 18988
"bundled": 168517,
"minified": 58191,
"gzipped": 19016
},
"dist/react-jss.min.js": {
"bundled": 111704,
"minified": 41522,
"gzipped": 14086
"bundled": 111849,
"minified": 41586,
"gzipped": 14098
},
"dist/react-jss.cjs.js": {
"bundled": 26415,
"minified": 11502,
"gzipped": 3809
"bundled": 26550,
"minified": 11551,
"gzipped": 3816
},
"dist/react-jss.esm.js": {
"bundled": 25453,
"minified": 10667,
"gzipped": 3688,
"bundled": 25588,
"minified": 10716,
"gzipped": 3693,
"treeshaked": {
"rollup": {
"code": 1841,
9 changes: 6 additions & 3 deletions packages/react-jss/src/withStyles.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @flow
import React, {Component, type ComponentType, type Node} from 'react'
import isInBrowser from 'is-in-browser'
import hoistNonReactStatics from 'hoist-non-react-statics'
import {type StyleSheet, type Classes} from 'jss'
import {ThemeContext} from 'theming'
@@ -119,8 +118,12 @@ const withStyles = <Theme>(styles: Styles<Theme>, options?: HOCOptions<Theme> =
if (sheet && registry) {
registry.add(sheet)
}
if (isInBrowser) {
WithStyles.manage(props, this.state)
}

componentDidMount() {
const {props, state} = this
if (props && state) {
WithStyles.manage(props, state)
}
}