TanStackT
TanStack3y ago
1 reply
moderate-tomato

Is useEffect the best way to handle changes in data?

I have data that can change on the server and when it does I want certain things to happen in the app (such as opening a popup).

I am currently handling this like this:
const fundingStatus = useFundingStatus()

useEffect(() => {
  if (fundingStatus === 'CANCELED') {
      startRefund()
      return
  }
  if (fundingStatus === 'WRONG_FUNDING_AMOUNT') {
    showWronglyFundedPopup()
    return
  }
}, [fundingStatus])


Is this the best way to achieve the idea of "onSuccess only for one instance" or is there some better way?
Was this page helpful?