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

Add useMemo() for value fetching hooks #41

Merged
merged 1 commit into from
May 25, 2020

Conversation

ypresto
Copy link
Contributor

@ypresto ypresto commented Sep 14, 2019

React.memo() will work as expected with this!

Without this, rerender (e.g. calling setState() of useState() in the render function) will cause useCollectionData() and useDocumentData() (and realtime database counter parts) to return different reference (!==) of data.

@ypresto ypresto changed the title Add useMemo for useCollectionData() and useDocumentData() Add useMemo() for value fetching hooks Sep 14, 2019
@thomasglachant
Copy link

thomasglachant commented Oct 1, 2019

Very usefull pull request !
Can anyone merge this please ? ( @chrisbianca )

@tmc
Copy link

tmc commented Feb 8, 2020

ping

@sdemjanenko
Copy link
Contributor

Could this PR be merged and a new release cut? I'm running into an issue that this PR solves.

@gwendall
Copy link

gwendall commented May 3, 2020

+1

@MartinSeeler
Copy link

ping++

@chrisbianca chrisbianca merged commit bb0f815 into CSFrequency:master May 25, 2020
@chrisbianca
Copy link
Contributor

Apologies that this has taken so long to be integrated into the library, but it's now landed as part of v2.2.0: https://github.com/CSFrequency/react-firebase-hooks/releases/tag/v2.2.0

Thank you @ypresto for the PR.

@ypresto ypresto deleted the memo-data branch May 26, 2020 14:15
@grubersjoe
Copy link

grubersjoe commented Jun 6, 2020

This seems to work for useCollectionData() 👍. When I use useCollectionDataOnce() I still encounter different references in useEffect, however. Shouldn't this work for useCollectionDataOnce() too? Or is my understanding wrong?

@harish-aka-shivi
Copy link

harish-aka-shivi commented Jul 23, 2020

I also faced the same issue with useCollectionDataOnce as @grubersjoe mentioned. I think it should be same with useCollectionDataOnce

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.