-
I've done a bit of research, but couldn't see if anyone else has done this. Is it alright to pass a conditional stale time to react-query? My use-case is that I want to poll data if the response is I'm just a bit concerned if this is a footgun, or if this is something I shouldn't be doing? const [isPending, setIsPending] = useState(false)
const handleSuccess = (data: IbcStatusQueryData) => {
setIsPending(data.status === 'pending')
}
return useQuery(queryKeys.getTransactionStatus({ id: transaction.id }), handleRequest, {
onSuccess: handleSuccess,
staleTime: isPending ? 30 * 1000 : Infinity
}) I'd like to avoid making the request if the value has anything else. It's unnecessary; in addition, this query will be used in a component inside a list. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This discussion happened elsewhere (if anyone's curious): https://twitter.com/TkDodo/status/1610214061894942723 |
Beta Was this translation helpful? Give feedback.
This discussion happened elsewhere (if anyone's curious): https://twitter.com/TkDodo/status/1610214061894942723