Both of the following work and the child component doesn't rerender, but which one is preferable and why?
This one using a const
and an updater function
const [count, setCount] = useState(0)
const increment = useCallback(() => {
setCount(c => c + 1)
}, [])
Or this one using a let
and a ++
operator
let [count, setCount] = useState(0)
const increment = useCallback(() => {
setCount(count++)
}, [])