Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve multiple argument example in README #201

Merged
merged 2 commits into from
Dec 16, 2019
Merged

Conversation

shuding
Copy link
Member

@shuding shuding commented Dec 16, 2019

We shouldn't recommend useMemo(() => ({ id }), [id]). It's not elegant, and the cache is not-reusable.

For example id changes from 1 → 2 → 1, and the cache can not be reused since A !== C:

const A = useMemo(() => ({ id: 1 }), [1])
const B = useMemo(() => ({ id: 2 }), [2])
const C = useMemo(() => ({ id: 1 }), [1])

@pacocoursey pacocoursey merged commit 700cd6c into master Dec 16, 2019
@pacocoursey pacocoursey deleted the update-readme branch December 16, 2019 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants