in some code i have seen the below usage of useMemo. is this valid? i've been wondering what is advantage of this and why can't we simply use const?
const id = React.useMemo(() => "sort_id", []);
in some code i have seen the below usage of useMemo. is this valid? i've been wondering what is advantage of this and why can't we simply use const?
const id = React.useMemo(() => "sort_id", []);
const gets reinstantiated on every render, whereas useMemo will hold the same reference until the component is unmounted/remounted.