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.
@@ -1,10 +1,10 @@
1
1
  import { useState, useContext } from 'react';
2
- import { useIsomorphicLayoutEffect } from 'extra-react-hooks';
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
- useIsomorphicLayoutEffect(() => {
7
+ useIIFE(() => {
8
8
  let oldValue = value;
9
9
  return store.subscribe(state => {
10
10
  const newValue = selector(state);
@@ -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,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAE7D,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;IAGtE,yBAAyB,CAAC,GAAG,EAAE;QAC7B,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,E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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.0",
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.6.1",
37
- "@commitlint/config-conventional": "^19.6.0",
38
- "@eslint/js": "^9.18.0",
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.1.0",
41
- "@types/react": "^19.0.7",
40
+ "@testing-library/react": "^16.2.0",
41
+ "@types/react": "^19.1.0",
42
42
  "@vitejs/plugin-react": "^4.3.4",
43
- "eslint": "^9.18.0",
43
+ "eslint": "^9.23.0",
44
44
  "eslint-plugin-react": "^7.37.4",
45
- "eslint-plugin-react-hooks": "^5.1.0",
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.0.0",
51
- "react-dom": "^19.0.0",
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.7.3",
57
- "typescript-eslint": "^8.20.0",
58
- "typescript-transform-paths": "^3.5.3",
59
- "vite": "^6.0.7",
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": "^2.1.8"
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.0",
67
- "extra-utils": "^5.17.0"
66
+ "extra-react-hooks": "^0.8.4",
67
+ "extra-utils": "^5.19.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "immer": "^10.0.2",
@@ -1,5 +1,5 @@
1
1
  import { useState, useContext } from 'react'
2
- import { useIsomorphicLayoutEffect } from 'extra-react-hooks'
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
- // `useEffect` will be called too late, resulting in not subscribing in time.
15
- useIsomorphicLayoutEffect(() => {
14
+ useIIFE(() => {
16
15
  let oldValue = value
17
16
 
18
17
  return store.subscribe(state => {