You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/react-jss.md
+16-60Lines changed: 16 additions & 60 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
# JSS integration with React
2
2
3
-
React-JSS integrates [JSS](https://github.com/cssinjs/jss) with React using the new Hooks API as well as a Styled Component API. JSS and the [default preset](https://github.com/cssinjs/jss/tree/master/packages/jss-preset-default) are already built in.
3
+
React-JSS integrates [JSS](https://github.com/cssinjs/jss) with React using the new Hooks API. JSS and the [default preset](https://github.com/cssinjs/jss/tree/master/packages/jss-preset-default) are already built in.
4
4
5
5
Try it out in the [playground](https://codesandbox.io/s/j3l06yyqpw).
6
6
7
-
**HOC based API is deprecated as of v10 and will be removed in v11. HOC specific docs are available [here](./react-jss-hoc.md).**
7
+
**HOC based API is deprecated as of v10 and will be removed in v11. You can still make a lazy migration like described [here](https://reacttraining.com/blog/using-hooks-in-classes/). HOC specific docs are available [here](./react-jss-hoc.md).**
8
8
9
-
Benefits compared to using the core JSS package directly:
9
+
### Benefits compared to using the core JSS package directly:
10
10
11
11
- Dynamic Theming - allows context based theme propagation and runtime updates.
12
12
- Critical CSS extraction - only CSS from rendered components gets extracted.
13
13
- Lazy evaluation - Style Sheets are created when a component mounts and removed when it's unmounted.
14
14
- The static part of a Style Sheet will be shared between all elements.
15
-
- Function values and rules are updated automatically with props as an argument.
15
+
- Function values and rules are updated automatically with any data you pass to `useStyles(data)`. You can pass props, state or anything from context for example.
In case you need to access the theme without rendering any CSS, you can also use `useTheme()` standalone.
262
-
263
-
```javascript
264
-
importReactfrom'react'
265
-
import {useTheme} from'react-jss'
266
-
267
-
constButton= () => {
268
-
consttheme=useTheme()
269
-
return<button>I can access {theme.colorPrimary}</button>
270
-
}
271
-
```
272
-
273
229
## Using custom Theming Context
274
230
275
231
Use _namespaced_ themes so that a set of UI components gets no conflicts with another set of UI components from a different library also using `react-jss` or in case you want to use the same theme from another context that is already used in your app.
0 commit comments