Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit866bf96

Browse files
committed
docs(store): addwithProvider example, updateinitialState prop, and add extra details to local state management docs
1 parenta2073f3 commit866bf96

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

‎apps/docs/pages/store/local-state-management.mdx‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ const Counter = ({ customProp }: { customProp: string }) => {
4545
const App= ()=> {
4646
return (
4747
<>
48-
<storeContext.ProviderinitialValue={{ count:1 }}>
48+
<CounterStoreProviderinitialState={{ count:1 }}>
4949
<CountercustomProp="example" />
50-
</storeContext.Provider>
51-
<storeContext.ProviderinitialValue={{ count:5 }}>
50+
</CounterStoreProvider>
51+
<CounterStoreProviderinitialState={{ count:5 }}>
5252
<Counter />
53-
</storeContext.Provider>
53+
</CounterStoreProvider>
5454
</>
5555
);
5656
};
@@ -76,16 +76,16 @@ const Counter = withCounterStoreProvider(
7676
const App= ()=> {
7777
return (
7878
<>
79-
<CounterinitialValue={{ count:1 }}customProp="example" />
80-
<CounterinitialValue={{ count:5 }}customProp="example" />
79+
<CounterinitialState={{ count:1 }}customProp="example" />
80+
<CounterinitialState={{ count:5 }}customProp="example" />
8181
</>
8282
);
8383
};
8484
```
8585

8686
##Merging Local and Global State
8787

88-
When creating a local instance of a store with`<ProviderinitialValue={...}>`, the`initialValue` will be merged with the global store's initial value:
88+
When creating a local instance of a store with`<ProviderinitialState={...}>`, the`initialState` will be merged with the global store's initial value:
8989

9090
```tsx
9191
const globalStore=store({
@@ -97,7 +97,7 @@ const storeContext = createStoreContext(globalStore);
9797

9898
const App= ()=> {
9999
return (
100-
<storeContext.ProviderinitialValue={{ count:5 }}>
100+
<storeContext.ProviderinitialState={{ count:5 }}>
101101
{/* count will be 5, but name will still be 'John' from the global store*/}
102102
<Counter />
103103
</storeContext.Provider>
@@ -135,7 +135,7 @@ function App() {
135135
}
136136
```
137137

138-
##Is it possible to create a local store,witout creating a global store?
138+
##Is it possible to create a local store,without creating a global store?
139139

140140
Yes this is actually the default behaviour. This is because the`store` function does NOT create a store instance until a non-builder method is called.
141141

‎apps/docs/pages/store/onChange-and-effects.mdx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@ Here is a super simplified version of `createStoreContext` to show how the effec
121121
```tsx
122122
exportfunction createStoreContext(store) {
123123
const Provider= ()=> {
124-
const storeInstance=React.useRef(store.create(localInitialValue));
124+
const storeInstance=React.useRef(store.create(localinitialState));
125125

126126
React.useEffect(()=> {
127+
const instance=storeInstance.current;
128+
insatnce.subscribeToEffecs();
127129
return ()=> {
128-
storeInstance.current.unsubscribeFromEffects();
130+
instance.unsubscribeFromEffects();
129131
};
130132
}, []);
131133

@@ -137,5 +139,3 @@ export function createStoreContext(store) {
137139
};
138140
}
139141
```
140-
141-

‎packages/store/README.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const counterStore: StoreApi<
9797

9898
```
9999

100-
Note: store(initialValue) and store.state(initialValue) are equivalent, it's just a matter of preference.
100+
Note: store(initialState) and store.state(initialState) are equivalent, it's just a matter of preference.
101101

102102
###Nested object store example:
103103

@@ -159,4 +159,3 @@ Contributions are welcome! Please read our [contributing guide](link-to-contribu
159159
###License
160160

161161
This project is licensed under the[MIT License](link-to-license). See the LICENSE file for details.
162-

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp