Hoppa till huvudinnehåll

Ett inlägg taggade me "react"

Visa Alla Taggar

Difference between useState and useMemo

· En minut att läsa
Filip Tammergård
Software Engineer at Einride

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])