Skip to content

Commit b04d2eb

Browse files
authored
Update README.md
1 parent c323af8 commit b04d2eb

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ const Component = () => {
2727
};
2828
```
2929

30-
## Document
31-
### Syntactic sugar
30+
## Syntactic sugar
3231
```js
3332
const {useSharedState} = require('react-hooks-shared-state');
3433
```
@@ -38,22 +37,28 @@ sharedState.useState()
3837
```
3938
`useSharedState` and `sharedState.useState` are the same one.
4039

41-
### setSharedState(state)
40+
## setSharedState(state)
41+
```js
42+
const {setSharedState} = require('react-hooks-shared-state');
43+
```
4244
Assign a new stateful value.
43-
#### Parameter `state`
45+
### Parameter `state`
4446
Type: `any`
4547
Required: `required`
4648

47-
### useSharedState(path, initialState)
49+
## useSharedState(path, initialState)
50+
```js
51+
const {useSharedState} = require('react-hooks-shared-state');
52+
```
4853
Returns a stateful value, and a function to update it.
49-
#### Parameter `path`
54+
### Parameter `path`
5055
Type: `string`
5156
Required: `optional`
5257
The object path of the state.
5358
When the path is null it will return the state(root).
5459
If you just want to use a part of state in the component, pass the object path.
5560

56-
#### Parameter `initialState`
61+
### Parameter `initialState`
5762
Type: `any`
5863
Required: `optional`
5964
The initial state.

0 commit comments

Comments
 (0)