DEV Community

loading...
Cover image for An Experience I had using react hooks (useEffect, useState). Not the best practice but why did it work🤔🤔

An Experience I had using react hooks (useEffect, useState). Not the best practice but why did it work🤔🤔

niidarku profile image Niidarku ・1 min read

So I was trying to perform an update on a component being mounted by fetching data from an api into a react app, I prefer functional components with hooks to class components. Upon trying to use the useEffect hook I mistakenly used useState in the same form I would have use the useEffect hook and to my surprise the request went through and the component was correctly updated 🤔.

react #hooks

Discussion (0)

Forem Open with the Forem app