Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
show usage of useLazyQuery
const [
execGetThreadData,
{ called, data: getThreadData, error, loading, refetch }
] = useLazyQuery(GetThread);
useEffect(() => {
if (called && loading) {
log("thread is loading");
} else if (error) {
log(error);
} else if (!called && !getThreadData && id) {
execGetThreadData({
variables: { id, incViewCount: true }
});
} else if (called && getThreadData) {
if (thread == getThreadData.getThread) {
refetch({ id, incViewCount: true });
} else {
setThread(getThreadData.getThread);
}
}
}, [getThreadData, id, userProfile]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment