extra-react-store 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,21 +15,21 @@ interface IState {
15
15
  count: number
16
16
  }
17
17
 
18
- const context = createStoreContext<IState>()
18
+ const Context = createStoreContext<IState>()
19
19
 
20
20
  function App() {
21
21
  const store = useMemo<Store<IState>>(() => new Store({ count: 0 }), [])
22
22
 
23
23
  return (
24
- <context.Provider value={store}>
24
+ <Context.Provider value={store}>
25
25
  <Viewer />
26
26
  <Controller />
27
- </context.Provider>
27
+ </Context.Provider>
28
28
  )
29
29
  }
30
30
 
31
31
  function Viewer() {
32
- const count = useSelector(context, state => state.count)
32
+ const count = useSelector(Context, state => state.count)
33
33
 
34
34
  return (
35
35
  <span>{count}</span>
@@ -37,7 +37,7 @@ function Viewer() {
37
37
  }
38
38
 
39
39
  function Controller() {
40
- const update = useUpdater<IState>(context)
40
+ const update = useUpdater<IState>(Context)
41
41
 
42
42
  return (
43
43
  <button onClick={() => update(increment)}>Increment</button>
@@ -7,7 +7,7 @@ export function useSelector(context, selector) {
7
7
  const newValue = selector(state);
8
8
  setValue(newValue);
9
9
  });
10
- }, [store, value]);
10
+ }, [store, selector, value]);
11
11
  return value;
12
12
  }
13
13
  //# sourceMappingURL=use-selector.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-selector.js","sourceRoot":"","sources":["../src/use-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGvD,MAAM,UAAU,WAAW,CACzB,OAA4B,EAC5B,QAAiC;IAEjC,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;IACjC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IAEpE,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAC7B,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;YAGhC,QAAQ,CAAC,QAAQ,CAAC,CAAA;QACpB,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IAElB,OAAO,KAAK,CAAA;AACd,CAAC"}
1
+ {"version":3,"file":"use-selector.js","sourceRoot":"","sources":["../src/use-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGvD,MAAM,UAAU,WAAW,CACzB,OAA4B,EAC5B,QAAiC;IAEjC,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;IACjC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IAEpE,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAC7B,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;YAGhC,QAAQ,CAAC,QAAQ,CAAC,CAAA;QACpB,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAA;IAE5B,OAAO,KAAK,CAAA;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-react-store",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "files": [
@@ -15,7 +15,7 @@ export function useSelector<State, Value>(
15
15
  // 若新旧状态引用相等, 不会发生重新渲染.
16
16
  setValue(newValue)
17
17
  })
18
- }, [store, value])
18
+ }, [store, selector, value])
19
19
 
20
20
  return value
21
21
  }