-
I'd like to do something like const { isLoading, data, initialFetch /* doesn't exist */ } = useQuery('stuff', () => fetchStuff());
// further down
<button onClick={() => { initialFetch(); /*...*/ }}>Open modal<.button> Basically the data would not be fetched until we call intialFetch Is this possible? I believe a workaround is to do const [open, setOpen] = useState(false);
const { isLoading, data, initialFetch } = useQuery('stuff-'+open, () => open && fetchStuff());
// further down
<button onClick={() => { setOpen(true); /*...*/ }}>Open modal<.button> but not ideal maybe |
Beta Was this translation helpful? Give feedback.
Answered by
TkDodo
Jun 19, 2021
Replies: 1 comment 2 replies
-
This is how I would do it: https://twitter.com/tkdodo/status/1374452337046032395 |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
caub
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is how I would do it: https://twitter.com/tkdodo/status/1374452337046032395