@tanstack/react-store
Advanced tools
Comparing version 0.0.1-beta.113 to 0.0.1-beta.118
@@ -19,3 +19,26 @@ /** | ||
function useStore(store, selector = d => d) { | ||
// const isMountedRef = React.useRef(false) | ||
// const [state, setState] = React.useState<{ ref: TSelected }>({ | ||
// ref: undefined!, | ||
// }) | ||
const slice = withSelector.useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, shallow); | ||
// if (!isMountedRef.current) { | ||
// state.ref = slice | ||
// } | ||
// if (slice !== state.ref) { | ||
// setState({ ref: slice }) | ||
// } | ||
// React.useEffect(() => { | ||
// isMountedRef.current = true | ||
// return () => { | ||
// isMountedRef.current = false | ||
// } | ||
// }, []) | ||
// return state.ref | ||
return slice; | ||
@@ -22,0 +45,0 @@ } |
@@ -15,3 +15,26 @@ /** | ||
function useStore(store, selector = d => d) { | ||
// const isMountedRef = React.useRef(false) | ||
// const [state, setState] = React.useState<{ ref: TSelected }>({ | ||
// ref: undefined!, | ||
// }) | ||
const slice = useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, shallow); | ||
// if (!isMountedRef.current) { | ||
// state.ref = slice | ||
// } | ||
// if (slice !== state.ref) { | ||
// setState({ ref: slice }) | ||
// } | ||
// React.useEffect(() => { | ||
// isMountedRef.current = true | ||
// return () => { | ||
// isMountedRef.current = false | ||
// } | ||
// }, []) | ||
// return state.ref | ||
return slice; | ||
@@ -18,0 +41,0 @@ } |
@@ -14,7 +14,7 @@ { | ||
"name": "store/build/esm/index.js", | ||
"uid": "5eea-10" | ||
"uid": "e526-10" | ||
}, | ||
{ | ||
"name": "react-store/src/index.tsx", | ||
"uid": "5eea-12" | ||
"uid": "e526-12" | ||
} | ||
@@ -29,20 +29,20 @@ ] | ||
"nodeParts": { | ||
"5eea-10": { | ||
"e526-10": { | ||
"renderedLength": 1359, | ||
"gzipLength": 537, | ||
"brotliLength": 0, | ||
"mainUid": "5eea-9" | ||
"mainUid": "e526-9" | ||
}, | ||
"5eea-12": { | ||
"renderedLength": 754, | ||
"gzipLength": 343, | ||
"e526-12": { | ||
"renderedLength": 1244, | ||
"gzipLength": 505, | ||
"brotliLength": 0, | ||
"mainUid": "5eea-11" | ||
"mainUid": "e526-11" | ||
} | ||
}, | ||
"nodeMetas": { | ||
"5eea-9": { | ||
"e526-9": { | ||
"id": "/packages/store/build/esm/index.js", | ||
"moduleParts": { | ||
"index.production.js": "5eea-10" | ||
"index.production.js": "e526-10" | ||
}, | ||
@@ -52,17 +52,17 @@ "imported": [], | ||
{ | ||
"uid": "5eea-11" | ||
"uid": "e526-11" | ||
} | ||
] | ||
}, | ||
"5eea-11": { | ||
"e526-11": { | ||
"id": "/packages/react-store/src/index.tsx", | ||
"moduleParts": { | ||
"index.production.js": "5eea-12" | ||
"index.production.js": "e526-12" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "5eea-13" | ||
"uid": "e526-13" | ||
}, | ||
{ | ||
"uid": "5eea-9" | ||
"uid": "e526-9" | ||
} | ||
@@ -73,3 +73,3 @@ ], | ||
}, | ||
"5eea-13": { | ||
"e526-13": { | ||
"id": "use-sync-external-store/shim/with-selector", | ||
@@ -80,3 +80,3 @@ "moduleParts": {}, | ||
{ | ||
"uid": "5eea-11" | ||
"uid": "e526-11" | ||
} | ||
@@ -83,0 +83,0 @@ ], |
@@ -71,3 +71,26 @@ /** | ||
function useStore(store, selector = d => d) { | ||
// const isMountedRef = React.useRef(false) | ||
// const [state, setState] = React.useState<{ ref: TSelected }>({ | ||
// ref: undefined!, | ||
// }) | ||
const slice = withSelector.useSyncExternalStoreWithSelector(store.subscribe, () => store.state, () => store.state, selector, shallow); | ||
// if (!isMountedRef.current) { | ||
// state.ref = slice | ||
// } | ||
// if (slice !== state.ref) { | ||
// setState({ ref: slice }) | ||
// } | ||
// React.useEffect(() => { | ||
// isMountedRef.current = true | ||
// return () => { | ||
// isMountedRef.current = false | ||
// } | ||
// }, []) | ||
// return state.ref | ||
return slice; | ||
@@ -74,0 +97,0 @@ } |
{ | ||
"name": "@tanstack/react-store", | ||
"author": "Tanner Linsley", | ||
"version": "0.0.1-beta.113", | ||
"version": "0.0.1-beta.118", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "tanstack/react-store", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
168456
422