@choksheak/react-utils 0.1.7 → 0.1.8
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/docs/classes/sharedQuery.SharedQuery.html +5 -5
- package/docs/classes/sharedState.SharedState.html +2 -2
- package/docs/classes/sharedState.SharedStateConfig.html +3 -3
- package/docs/classes/utils_storage.InMemoryStorageAdapter.html +2 -2
- package/docs/classes/utils_storage.IndexedDbAdapter.html +2 -2
- package/docs/classes/utils_storage.LocalStorageAdapter.html +2 -2
- package/docs/functions/sharedQuery.sharedQuery.html +1 -1
- package/docs/functions/sharedQuery.useQuery.html +1 -1
- package/docs/functions/sharedState.sharedState.html +1 -1
- package/docs/functions/sharedState.useSharedState.html +1 -1
- package/docs/functions/sharedState.useSharedStateSetter.html +1 -1
- package/docs/functions/sharedState.useSharedStateValue.html +1 -1
- package/docs/functions/utils_storage.getStorageAdapter.html +1 -1
- package/docs/functions/utils_stringify.stringifyDeterministicForKeys.html +1 -1
- package/docs/types/sharedQuery.FetchFn.html +1 -1
- package/docs/types/sharedQuery.FetchedData.html +2 -2
- package/docs/types/sharedQuery.QueryStateValue.html +2 -2
- package/docs/types/sharedQuery.SharedQueryOptions.html +1 -1
- package/docs/types/sharedQuery.SharedQueryState.html +1 -1
- package/docs/types/sharedState.SharedStateOptions.html +1 -1
- package/docs/types/utils_storage.StorageAdapter.html +2 -2
- package/docs/types/utils_storage.StorageOptions.html +2 -2
- package/docs/variables/fetcher.fetcher.html +1 -1
- package/docs/variables/fetcher.fetcherWithRetries.html +1 -1
- package/package.json +1 -1
- package/sharedQuery.js +3 -3
- package/sharedQuery.mjs +3 -3
- package/sharedState.js +3 -3
- package/sharedState.mjs +3 -3
- package/src/sharedState.ts +3 -3
package/sharedState.js
CHANGED
|
@@ -247,10 +247,10 @@ function sharedState(defaultValue, options) {
|
|
|
247
247
|
function useSharedState(state) {
|
|
248
248
|
state.initDefaultValueOnce();
|
|
249
249
|
const value = (0, import_react.useSyncExternalStore)(
|
|
250
|
-
state.subscribe,
|
|
251
|
-
state.getSnapshot,
|
|
250
|
+
(onStoreChange) => state.subscribe(onStoreChange),
|
|
251
|
+
() => state.getSnapshot(),
|
|
252
252
|
// getServerSnapshot is needed to prevent SSR dev errors in nextjs.
|
|
253
|
-
state.getSnapshot
|
|
253
|
+
() => state.getSnapshot()
|
|
254
254
|
);
|
|
255
255
|
return [value, state.setValue];
|
|
256
256
|
}
|
package/sharedState.mjs
CHANGED
|
@@ -218,10 +218,10 @@ function sharedState(defaultValue, options) {
|
|
|
218
218
|
function useSharedState(state) {
|
|
219
219
|
state.initDefaultValueOnce();
|
|
220
220
|
const value = useSyncExternalStore(
|
|
221
|
-
state.subscribe,
|
|
222
|
-
state.getSnapshot,
|
|
221
|
+
(onStoreChange) => state.subscribe(onStoreChange),
|
|
222
|
+
() => state.getSnapshot(),
|
|
223
223
|
// getServerSnapshot is needed to prevent SSR dev errors in nextjs.
|
|
224
|
-
state.getSnapshot
|
|
224
|
+
() => state.getSnapshot()
|
|
225
225
|
);
|
|
226
226
|
return [value, state.setValue];
|
|
227
227
|
}
|
package/src/sharedState.ts
CHANGED
|
@@ -205,10 +205,10 @@ export function useSharedState<T>(
|
|
|
205
205
|
state.initDefaultValueOnce();
|
|
206
206
|
|
|
207
207
|
const value = useSyncExternalStore(
|
|
208
|
-
state.subscribe,
|
|
209
|
-
state.getSnapshot,
|
|
208
|
+
(onStoreChange) => state.subscribe(onStoreChange),
|
|
209
|
+
() => state.getSnapshot(),
|
|
210
210
|
// getServerSnapshot is needed to prevent SSR dev errors in nextjs.
|
|
211
|
-
state.getSnapshot,
|
|
211
|
+
() => state.getSnapshot(),
|
|
212
212
|
);
|
|
213
213
|
|
|
214
214
|
return [value, state.setValue];
|