File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,7 @@ const Component = () => {
2727};
2828```
2929
30- ## Document
31- ### Syntactic sugar
30+ ## Syntactic sugar
3231``` js
3332const {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+ ```
4244Assign a new stateful value.
43- #### Parameter ` state `
45+ ### Parameter ` state `
4446Type: ` any `
4547Required: ` required `
4648
47- ### useSharedState(path, initialState)
49+ ## useSharedState(path, initialState)
50+ ``` js
51+ const {useSharedState } = require (' react-hooks-shared-state' );
52+ ```
4853Returns a stateful value, and a function to update it.
49- #### Parameter ` path `
54+ ### Parameter ` path `
5055Type: ` string `
5156Required: ` optional `
5257The object path of the state.
5358When the path is null it will return the state(root).
5459If you just want to use a part of state in the component, pass the object path.
5560
56- #### Parameter ` initialState `
61+ ### Parameter ` initialState `
5762Type: ` any `
5863Required: ` optional `
5964The initial state.
You can’t perform that action at this time.
0 commit comments