Difference between useState and useMemo
· One min read
The title of this post might seem ridiculous. Of course useState
and useMemo
are different.
But in one sense, they are quite similar.
Consider this example:
const [state] = useState(() => {
return calculateSomething(input)
})
const memo = useMemo(() => {
return calculateSomething(input)
}, [input])