Difference between useState and useMemo
· En minut att läsa
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])