-
Notifications
You must be signed in to change notification settings - Fork 306
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
Feature: Allow an initial value to be returned by the hooks #190
Comments
Hi Dylan, this sounds like it would be a very useful feature so am more than happy to review a PR for it. As you say it should be a relatively simple change, but shout if you have any issues and I am happy to take a look myself. |
Ok awesome. will try to find time this week to take a look and see how far I get! |
So, I finally got a local copy of react-firebase-hooks hooked up to my local project.
|
NextJS seems to have some issues with Firebase v9 so my plan is to raise the PR against the v3 branch and let you pull it into master later. |
In NextJS the idea is that you preload the data at build time. This then gets passed to your component via props.
If I have a component that uses say useCollectionData, it would be useful to specify an initial value that the hook should return whilst the data is loading. As soon as the firebase query has loaded, this value would be ignored and replaced with the value from the firebase query.
It is currently possible to do this outside of the firebase hook but it's a little awkward and this would really simplify the code for this usecase (i.e any nextjs project)
I think it'd be a pretty simple change so happy to put up a PR if you'd be interested in accepting a feature like this.
Thanks,
Dylan.
The text was updated successfully, but these errors were encountered: