DEV Community

Discussion on: Introduction to React.memo, useMemo and useCallback

Collapse
 
machy44 profile image
machy44

I believe you figured out why in meantime but I will answer anyway.
const increaseCounter2 = React.useCallback(() => {
setCount2(count2 => count1 + 1)
}, [])
Because when state is set author uses count1 + 1. I believe he wanted to write count2 + 1 and that this is syntax error.