Amy Blankenship
Jun 21, 2023

--

The problem is actually that you used useEffect and setState when you could have and should have used useMemo (as you did in the second example). Whether you do that inside or outside your component doesn't matter--it's doing it the correct way that's important.

--

--

Amy Blankenship
Amy Blankenship

Written by Amy Blankenship

Full Stack developer at fintech company. I mainly write about React, Javascript, Typescript, and testing.

No responses yet