Skip to content

Commit 4d815aa

Browse files
committed
update all TOCs
1 parent 26d21a9 commit 4d815aa

2 files changed

Lines changed: 41 additions & 37 deletions

File tree

docs/react-jss-hoc.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
## JSS HOC for React
1+
# JSS HOC for React
22

33
- [Basic](#basic)
4-
- [Server-side rendering](#server-side-rendering)
4+
- [Accessing the theme inside the styled component](#accessing-the-theme-inside-the-styled-component)
5+
- [Accessing the theme without a styled component](#accessing-the-theme-without-a-styled-component)
56
- [The inner component](#the-inner-component)
67
- [The inner ref](#the-inner-ref)
78
- [Decorators](#decorators)
9+
- [Injection order](#injection-order)
810
- [Usage with TypeScript](#usage-with-typescript)
911

10-
### Usage
12+
## Usage
1113

1214
React-JSS wraps your component with a [higher-order component](https://medium.com/@dan_abramov/mixins-are-dead-long-live-higher-order-components-94a0d2f9e750).
1315
It injects a `classes` prop, which is a simple map of rule names and generated class names.
1416

1517
Try it out in the [playground](https://codesandbox.io/s/j3l06yyqpw).
1618

17-
#### Basic
19+
## Basic
1820

1921
```javascript
2022
import React from 'react'
@@ -88,7 +90,7 @@ and
8890
}
8991
```
9092

91-
#### Accessing the theme inside the styled component
93+
## Accessing the theme inside the styled component
9294

9395
The theme will not be injecting into the wrapped component.
9496
To inject the theme into the wrapped component, pass the `injectTheme` option to `withStyles`.
@@ -119,7 +121,7 @@ const styles = theme => ({
119121
const StyledButton = withStyles(styles, {injectTheme: true})(Button)
120122
```
121123

122-
#### Accessing the theme without a styled component
124+
## Accessing the theme without a styled component
123125

124126
In case you need to access the theme but not render any CSS, you can also use `withTheme`. It is a Higher-order Component factory which takes a `React.Component` and maps the theme object from context to props. [Read more about `withTheme` in `theming`'s documentation.](https://github.com/cssinjs/theming#withthemecomponent)
125127

@@ -130,7 +132,7 @@ import {withTheme} from 'react-jss'
130132
const Button = withTheme(({theme}) => <button>I can access {theme.colorPrimary}</button>)
131133
```
132134

133-
#### The inner component
135+
## The inner component
134136

135137
```javascript
136138
import withStyles from 'react-jss'
@@ -140,7 +142,7 @@ const StyledComponent = withStyles({})(InnerComponent)
140142
console.log(StyledComponent.InnerComponent) // Prints out the inner component.
141143
```
142144

143-
#### The inner ref
145+
## The inner ref
144146

145147
To get a `ref` to the inner element, use the `ref` prop.
146148
We will forward the ref to the inner component.
@@ -161,7 +163,7 @@ const App = (
161163
)
162164
```
163165

164-
#### Decorators
166+
## Decorators
165167

166168
_Beware that [decorators are stage-2 proposal](https://tc39.github.io/proposal-decorators/), so there are [no guarantees that decorators will make its way into language specification](https://tc39.github.io/process-document/). Do not use it in production. Use it at your own risk and only if you know what you are doing._
167169

@@ -195,7 +197,7 @@ class Button extends Component {
195197
export default Button
196198
```
197199

198-
### Injection order
200+
## Injection order
199201

200202
Injection of style tags happens in the same order as the `withStyles()` invocation.
201203
Source order specificity is higher the lower style tag is in the tree. Therefore you should call `withStyles` of components you want to override first.
@@ -218,7 +220,7 @@ const Button = withStyles(buttonStyles)(() => (
218220
))
219221
```
220222

221-
### Usage with TypeScript
223+
## Usage with TypeScript
222224

223225
React JSS includes first class support for TypeScript. React JSS provides
224226
a `WithStyles` type which adds types for all of the injected props.

docs/react-jss.md

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## JSS integration with React
1+
# JSS integration with React
22

33
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.
44

@@ -14,27 +14,29 @@ Benefits compared to using the core JSS package directly:
1414
- The static part of a Style Sheet will be shared between all elements.
1515
- Function values and rules are updated automatically with props as an argument.
1616

17-
### Table of Contents
17+
## Table of Contents
1818

1919
- [Install](#install)
20-
- [Usage](#usage)
21-
- [Basic](#basic)
22-
- [Dynamic Values](#dynamic-values)
23-
- [Theming](#theming)
24-
- [Server-side rendering](#server-side-rendering)
25-
- [React tree traversing](#react-tree-traversing)
26-
- [Custom setup](#custom-setup)
27-
- [TypeScript](#typescript)
28-
29-
### Install
20+
- [Basic](#basic)
21+
- [Dynamic Values](#dynamic-values)
22+
- [Theming](#theming)
23+
- [Accessing the theme inside the styled component](#accessing-the-theme-inside-the-styled-component)
24+
- [Accessing the theme without styles](#accessing-the-theme-without-styles)
25+
- [Using custom Theming Context](#using-custom-theming-context)
26+
- [Server-side rendering](#server-side-rendering)
27+
- [React tree traversing](#react-tree-traversing)
28+
- [Custom setup](#custom-setup)
29+
- [Multi-tree setup](#multi-tree-setup)
30+
- [Injection order](#injection-order)
31+
- [TypeScript](#typescript)
32+
33+
## Install
3034

3135
```
3236
yarn add react-jss
3337
```
3438

35-
### Usage
36-
37-
#### Basic
39+
## Basic
3840

3941
```javascript
4042
import React from 'react'
@@ -106,7 +108,7 @@ and
106108
}
107109
```
108110

109-
#### Dynamic values
111+
## Dynamic values
110112

111113
You can use [function values](jss-syntax.md#function-values), Function rules and observables out of the box. Function values and function rules will receive a props object once the component receives new props or mounts for the first time.
112114

@@ -174,7 +176,7 @@ and
174176
}
175177
```
176178

177-
#### Theming
179+
## Theming
178180

179181
The idea is that you define a theme, wrap your application with `ThemeProvider` and pass the `theme` object to `ThemeProvider`. Later you can access theme in your styles creator function and using a `useTheme()` hook. After that, you may change your theme, and all your components will get the new theme automatically.
180182

@@ -222,7 +224,7 @@ const App = () => (
222224
)
223225
```
224226

225-
#### Accessing the theme inside the styled component
227+
## Accessing the theme inside the styled component
226228

227229
Use `useTheme()` hook to access the theme inside of the function component.
228230

@@ -253,7 +255,7 @@ const Button = ({children, ...props}) => {
253255
}
254256
```
255257

256-
#### Accessing the theme without styles
258+
## Accessing the theme without styles
257259

258260
In case you need to access the theme without rendering any CSS, you can also use `useTheme()` standalone.
259261

@@ -267,7 +269,7 @@ const Button = () => {
267269
}
268270
```
269271

270-
#### Using custom Theming Context
272+
## Using custom Theming Context
271273

272274
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.
273275

@@ -318,7 +320,7 @@ const App = () => (
318320
)
319321
```
320322

321-
#### Server-side rendering
323+
## Server-side rendering
322324

323325
After the application is mounted, you should remove the style tag used by critical CSS rendered server-side.
324326

@@ -354,7 +356,7 @@ export default function render(req, res) {
354356
}
355357
```
356358

357-
#### React tree traversing
359+
## React tree traversing
358360

359361
For traversing the React tree outside of the HTML rendering, you should add `disableStylesGeneration` property.
360362

@@ -380,7 +382,7 @@ async function main() {
380382
main()
381383
```
382384

383-
#### Custom setup
385+
## Custom setup
384386

385387
If you want to specify a JSS version and plugins to use, you should create your [own JSS instance](https://github.com/cssinjs/jss/blob/master/docs/jss-api.md#create-an-own-jss-instance), [setup plugins](https://github.com/cssinjs/jss/blob/master/docs/setup.md#setup-with-custom-plugins) and pass it to `JssProvider`.
386388

@@ -407,7 +409,7 @@ You can also access the default JSS instance.
407409
import {jss} from 'react-jss'
408410
```
409411

410-
#### Multi-tree setup
412+
## Multi-tree setup
411413

412414
In case you render multiple react rendering trees in one application, you will get class name collisions because every JssProvider rerender will reset the class names generator. If you want to avoid this, you can share the class names generator between multiple JssProvider instances.
413415

@@ -455,7 +457,7 @@ const Component = () => (
455457
)
456458
```
457459

458-
### Injection order
460+
## Injection order
459461

460462
Injection of style tags happens in the same order as the `createUseStyles()` invocation.
461463
Source order specificity is higher the lower style tag is in the tree. Therefore you should call `createUseStyles` of components you want to override first.
@@ -498,6 +500,6 @@ const Button = () => {
498500
}
499501
```
500502

501-
### TypeScript
503+
## TypeScript
502504

503505
TODO hooks support

0 commit comments

Comments
 (0)