Closed 0xHexE closed 2 years ago
Never mind you can use fetchQuery
something like this.
const [isRefreshing, setIsRefreshing] = useState(false);
const environment = useRelayEnvironment();
useEffect(() => {
if (isRefreshing) {
return;
}
setIsRefreshing(true);
fetchQuery(
environment as never,
CartQuery,
preloadedQuery.variables
).subscribe({
complete: () => {
setIsRefreshing(false);
},
error: () => {
setIsRefreshing(false);
},
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [atomValue]);
it will re-fetch the query.
But can be good for re-fetching with different params.
Because https://relay.dev/docs/guided-tour/refetching/refetching-queries-with-different-data/#when-using-usequeryloader--loadquery we can re-fetch the query using load query in some questions