@inglorious/react-store 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/index.jsx +9 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/react-store",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Official React bindings for @inglorious/store. Provides hooks and a Provider to connect your React components to the store.",
5
5
  "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -36,10 +36,10 @@
36
36
  "access": "public"
37
37
  },
38
38
  "dependencies": {
39
- "react-redux": "^9.1.2"
39
+ "react-redux": "^9.2.0"
40
40
  },
41
41
  "peerDependencies": {
42
- "react": "^18.2.0",
42
+ "react": "^19.2.0",
43
43
  "@inglorious/store": "5.2.0"
44
44
  },
45
45
  "devDependencies": {
package/src/index.jsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import { sendAction } from "@inglorious/store/client/dev-tools"
2
- import { Provider as BaseProvider, useDispatch, useSelector } from "react-redux"
2
+ import { useCallback } from "react"
3
+ import { Provider, useSelector } from "react-redux"
3
4
 
4
5
  const DEFAULT_CONFIG = { mode: "eager" }
5
6
  const ONE_SECOND = 1000
@@ -10,24 +11,21 @@ export function createReactStore(store, config = DEFAULT_CONFIG) {
10
11
  loop(store, config)
11
12
  }
12
13
 
13
- return { Provider, useSelector, useNotify }
14
+ return { Provider: StoreProvider, useSelector, useNotify }
14
15
 
15
- function Provider({ children }) {
16
- return <BaseProvider store={store}>{children}</BaseProvider>
16
+ function StoreProvider({ children }) {
17
+ return <Provider store={store}>{children}</Provider>
17
18
  }
18
19
 
19
20
  function useNotify() {
20
- const dispatch = useDispatch()
21
-
22
- return (type, payload) => {
23
- const action = { type, payload }
24
- dispatch(action)
21
+ return useCallback((type, payload) => {
22
+ store.notify(type, payload)
25
23
 
26
24
  if (config.mode === "eager") {
27
25
  store.update()
28
- sendAction(action, store.getState())
26
+ sendAction({ type, payload }, store.getState())
29
27
  }
30
- }
28
+ }, [])
31
29
  }
32
30
  }
33
31