DEV Community

Discussion on: Creating a Basic 'useQuery' React Hook

Collapse
 
rlaffers profile image
Richard Laffers

I think there is a flaw. In your success handler you forgot to check if the React component is still mounted. Trying to set local state on an unmounted component is an error. I recommend reading robinwieruch.de/react-fetching-data