This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
57
What is the purpose of useMemo-ing a whole component? A lack of trust of react change detection? Explicitly stating when the component should re-render?
Post Flair (click to view more posts with a particular flair)
Post Body
I've occasionally seen an entire component wrapped in a useMemo() like so:
const MyComponent = useMemo(() => <SomeComponent {...props} /, [// important props])
At first glance, this seems to be competing with React's job of determining when a component should re-render. I'm guessing how this goes down is:
- React decides component needs to re-render
- hits useMemo, which if the user defined props hasn't changed, just returns the memorized value effectively preventing the re-render
What is the purpose of memorizing a component?
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 11 months ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/reactjs/com...