Amy Blankenship
Jan 20, 2023

--

Your React example proves that if most people get something wrong, ChatGPT will also get it wrong. Since it doesn't wrap the functions in useMemo, they will have a different identity on every run of the function, causing a rerender all the way down. You would get a rerender anyway, because there aren't any React components in the returned expression to be memoized, but starting here and never fixing it is exactly how so many React codebases wind up with performance problems. It also keys off of index, which isn't great practice.

--

--

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