Skip to content

Commit 2c25cbb

Browse files
committed
use the derivedArray in the react hook so that you can get the sorted array
1 parent 4d50a3a commit 2c25cbb

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

packages/react-optimistic/src/useLiveQuery.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function useLiveQuery<
3232
}, [...deps, restart])
3333

3434
const state = useStore(compiledQuery.results.derivedState)
35-
let data: Array<ResultsFromContext<TResultContext>> | undefined
35+
const data = useStore(compiledQuery.results.derivedArray)
3636

3737
// Clean up on unmount
3838
useEffect(() => {
@@ -49,11 +49,6 @@ export function useLiveQuery<
4949

5050
return {
5151
state,
52-
get data() {
53-
if (!data) {
54-
data = Array.from(state.values())
55-
}
56-
return data
57-
},
52+
data,
5853
}
5954
}

0 commit comments

Comments
 (0)