fix: state update on unmounted hook and infinite query cache refetch not working
This commit is contained in:
@@ -83,9 +83,13 @@ InfiniteQuery<T, Outside, PageParam>
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
init();
|
||||
QueryBowl.of(context).onInfiniteQueriesUpdate<T, Outside, PageParam>(
|
||||
(newInfiniteQuery) {
|
||||
(newInfiniteQuery) async {
|
||||
if (newInfiniteQuery.queryKey != job.queryKey || !mounted()) return;
|
||||
infiniteQuery.value = newInfiniteQuery;
|
||||
if (!infiniteQuery.value.fetched &&
|
||||
infiniteQuery.value.isCachedData) {
|
||||
await infiniteQuery.value.refetchPages();
|
||||
}
|
||||
update();
|
||||
},
|
||||
);
|
||||
|
||||
@@ -11,5 +11,8 @@ const uuid = Uuid();
|
||||
|
||||
useForceUpdate() {
|
||||
final state = useState(false);
|
||||
return () => state.value = !state.value;
|
||||
final isMounted = useIsMounted();
|
||||
return () {
|
||||
if (isMounted()) state.value = !state.value;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user