extra-react-store 0.2.0 → 0.2.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/lib/use-selector.js +2 -2
- package/lib/use-selector.js.map +1 -1
- package/package.json +17 -17
- package/src/use-selector.ts +2 -3
package/lib/use-selector.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useState, useContext } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useIIFE } from 'extra-react-hooks';
|
|
3
3
|
import { isReferenceEqual } from 'extra-utils';
|
|
4
4
|
export function useSelector(context, selector, isEqual = isReferenceEqual) {
|
|
5
5
|
const store = useContext(context);
|
|
6
6
|
const [[value], setBox] = useState(() => [selector(store.getState())]);
|
|
7
|
-
|
|
7
|
+
useIIFE(() => {
|
|
8
8
|
let oldValue = value;
|
|
9
9
|
return store.subscribe(state => {
|
|
10
10
|
const newValue = selector(state);
|
package/lib/use-selector.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-selector.js","sourceRoot":"","sources":["../src/use-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"use-selector.js","sourceRoot":"","sources":["../src/use-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,MAAM,UAAU,WAAW,CACzB,OAA4B,EAC5B,QAAiC,EACjC,UAA2C,gBAAgB;IAE3D,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;IACjC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAA;IAEtE,OAAO,CAAC,GAAG,EAAE;QACX,IAAI,QAAQ,GAAG,KAAK,CAAA;QAEpB,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAC7B,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;YAEhC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;gBACjC,QAAQ,GAAG,QAAQ,CAAA;gBACnB,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAA;YACpB,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;IAE7C,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extra-react-store",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"files": [
|
|
@@ -33,38 +33,38 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@commitlint/cli": "^19.
|
|
37
|
-
"@commitlint/config-conventional": "^19.
|
|
38
|
-
"@eslint/js": "^9.
|
|
36
|
+
"@commitlint/cli": "^19.8.0",
|
|
37
|
+
"@commitlint/config-conventional": "^19.8.0",
|
|
38
|
+
"@eslint/js": "^9.23.0",
|
|
39
39
|
"@testing-library/dom": "^10.4.0",
|
|
40
|
-
"@testing-library/react": "^16.
|
|
41
|
-
"@types/react": "^19.0
|
|
40
|
+
"@testing-library/react": "^16.2.0",
|
|
41
|
+
"@types/react": "^19.1.0",
|
|
42
42
|
"@vitejs/plugin-react": "^4.3.4",
|
|
43
|
-
"eslint": "^9.
|
|
43
|
+
"eslint": "^9.23.0",
|
|
44
44
|
"eslint-plugin-react": "^7.37.4",
|
|
45
|
-
"eslint-plugin-react-hooks": "^5.
|
|
45
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
46
46
|
"husky": "4",
|
|
47
47
|
"immer": "^10.1.1",
|
|
48
48
|
"jsdom": "^26.0.0",
|
|
49
49
|
"npm-run-all": "^4.1.5",
|
|
50
|
-
"react": "^19.
|
|
51
|
-
"react-dom": "^19.
|
|
50
|
+
"react": "^19.1.0",
|
|
51
|
+
"react-dom": "^19.1.0",
|
|
52
52
|
"rimraf": "^6.0.1",
|
|
53
53
|
"standard-version": "^9.3.2",
|
|
54
54
|
"ts-patch": "^3.3.0",
|
|
55
55
|
"tslib": "^2.8.1",
|
|
56
|
-
"typescript": "5.
|
|
57
|
-
"typescript-eslint": "^8.
|
|
58
|
-
"typescript-transform-paths": "^3.5.
|
|
59
|
-
"vite": "^6.
|
|
56
|
+
"typescript": "5.8.2",
|
|
57
|
+
"typescript-eslint": "^8.29.0",
|
|
58
|
+
"typescript-transform-paths": "^3.5.5",
|
|
59
|
+
"vite": "^6.2.4",
|
|
60
60
|
"vite-tsconfig-paths": "^5.1.4",
|
|
61
|
-
"vitest": "^
|
|
61
|
+
"vitest": "^3.1.1"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@blackglory/prelude": "^0.4.0",
|
|
65
65
|
"@blackglory/structures": "^0.14.10",
|
|
66
|
-
"extra-react-hooks": "^0.8.
|
|
67
|
-
"extra-utils": "^5.
|
|
66
|
+
"extra-react-hooks": "^0.8.4",
|
|
67
|
+
"extra-utils": "^5.19.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"immer": "^10.0.2",
|
package/src/use-selector.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useContext } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { useIIFE } from 'extra-react-hooks'
|
|
3
3
|
import { StoreContext } from './types.js'
|
|
4
4
|
import { isReferenceEqual } from 'extra-utils'
|
|
5
5
|
|
|
@@ -11,8 +11,7 @@ export function useSelector<State, Value>(
|
|
|
11
11
|
const store = useContext(context)
|
|
12
12
|
const [[value], setBox] = useState(() => [selector(store.getState())])
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
useIsomorphicLayoutEffect(() => {
|
|
14
|
+
useIIFE(() => {
|
|
16
15
|
let oldValue = value
|
|
17
16
|
|
|
18
17
|
return store.subscribe(state => {
|