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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With