@sanity/react-loader
Advanced tools
Comparing version 0.7.2-pink-lizard to 0.8.0-pink-lizard
@@ -9,2 +9,22 @@ # Changelog | ||
## [0.8.0-pink-lizard](https://github.com/sanity-io/visual-editing/compare/react-loader-v0.7.2-pink-lizard...react-loader-v0.8.0-pink-lizard) (2023-11-09) | ||
### ⚠ BREAKING CHANGES | ||
* remove `startTransition` option | ||
### Bug Fixes | ||
* remove `startTransition` option ([25268ed](https://github.com/sanity-io/visual-editing/commit/25268ed021a3743853ba673afe8ada91a562e21f)) | ||
* set initial `loading` to `false` when hydrated ([415c2f5](https://github.com/sanity-io/visual-editing/commit/415c2f582a4873c33371bd52a7848352c1bcb189)) | ||
* set initial hydrated state consistently ([4d9676c](https://github.com/sanity-io/visual-editing/commit/4d9676c95a7f32d4166828bbd643eb35570f97fe)) | ||
### Dependencies | ||
* The following workspace dependencies were updated | ||
* dependencies | ||
* @sanity/core-loader bumped to 0.7.3-pink-lizard | ||
## [0.7.2-pink-lizard](https://github.com/sanity-io/visual-editing/compare/react-loader-v0.7.1-pink-lizard...react-loader-v0.7.2-pink-lizard) (2023-11-08) | ||
@@ -11,0 +31,0 @@ |
@@ -7,3 +7,2 @@ import type { ContentSourceMap } from '@sanity/client' | ||
import { QueryStoreState } from '@sanity/core-loader' | ||
import { TransitionFunction } from 'react' | ||
@@ -59,3 +58,2 @@ export declare const createQueryStore: ( | ||
} | ||
startTransition?: TransitionFunction | ||
} | ||
@@ -62,0 +60,0 @@ |
import { createQueryStore as createQueryStore$1 } from '@sanity/core-loader'; | ||
import { useState, useMemo, useEffect, startTransition } from 'react'; | ||
import { useState, useMemo, useEffect } from 'react'; | ||
const createQueryStore = options => { | ||
@@ -10,25 +10,17 @@ const { | ||
} = createQueryStore$1(options); | ||
const initialFetch = { | ||
loading: true, | ||
data: void 0, | ||
error: void 0, | ||
sourceMap: void 0 | ||
}; | ||
const DEFAULT_PARAMS = {}; | ||
const useQuery = (query2, params = DEFAULT_PARAMS, options2 = {}) => { | ||
const { | ||
startTransition: startTransition$1 = startTransition | ||
} = options2; | ||
const [initial] = useState(() => options2.initial); | ||
const $params = useMemo(() => JSON.stringify(params), [params]); | ||
const [snapshot, setSnapshot] = useState(() => ({ | ||
...initialFetch, | ||
data: initial?.data, | ||
sourceMap: initial?.sourceMap | ||
})); | ||
const [snapshot, setSnapshot] = useState(() => { | ||
const fetcher = createFetcherStore(query2, JSON.parse($params), initial); | ||
return fetcher.value; | ||
}); | ||
useEffect(() => { | ||
const fetcher = createFetcherStore(query2, JSON.parse($params), initial); | ||
const unlisten = fetcher.listen(snapshot2 => startTransition$1(() => setSnapshot(snapshot2))); | ||
const unlisten = fetcher.listen(snapshot2 => { | ||
setSnapshot(snapshot2); | ||
}); | ||
return () => unlisten(); | ||
}, [$params, initial, query2, startTransition$1]); | ||
}, [$params, initial, query2]); | ||
return snapshot; | ||
@@ -35,0 +27,0 @@ }; |
{ | ||
"name": "@sanity/react-loader", | ||
"version": "0.7.2-pink-lizard", | ||
"version": "0.8.0-pink-lizard", | ||
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/react-loader#readme", | ||
@@ -123,3 +123,3 @@ "bugs": { | ||
"dependencies": { | ||
"@sanity/core-loader": "0.7.2-pink-lizard" | ||
"@sanity/core-loader": "0.7.3-pink-lizard" | ||
}, | ||
@@ -126,0 +126,0 @@ "devDependencies": { |
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
380355
1528
+ Added@sanity/core-loader@0.7.3-pink-lizard(transitive)
- Removed@sanity/core-loader@0.7.2-pink-lizard(transitive)