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

[React Native/ Expo only] Add offline support 👀 #2

Closed
nandorojo opened this issue May 6, 2020 · 6 comments
Closed

[React Native/ Expo only] Add offline support 👀 #2

nandorojo opened this issue May 6, 2020 · 6 comments

Comments

@nandorojo
Copy link
Owner

nandorojo commented May 6, 2020

This issue only applies to mobile apps built with Expo. Firestore persistence works fine with this library with normal React.

Data should cache to AsyncStorage something like redux persist, and any mutations should somehow bubble up to happen later...🙃

If anyone stumbles upon this, would love help.

@nandorojo
Copy link
Owner Author

Relevant discussion from SWR: vercel/swr#16

@puchesjr
Copy link

Wouldn't this be possible by just using the Firestore option of enablePersistence=true?

@nandorojo
Copy link
Owner Author

nandorojo commented May 19, 2020

Yeah!

The only problem is that Firestore doesn't have persistence support for React Native / @expo, which I use primarily. But if you don't use React Native, then you're fine using the normal Firestore persistence.

There is a work-around for React Native here: https://gist.github.com/zwily/e9e97e0f9f523a72c24c7df01d889482 and https://github.com/firebase/firebase-js-sdk/blob/3c8f85d0185e3305f0ba7790d46eebb8e9e78e62/packages/firestore/test/util/node_persistence.ts (though this one might be slow on RN)

For more, see the original Firestore issue: firebase/firebase-js-sdk#436

@nandorojo nandorojo changed the title Add offline support 👀 [React Native] Add offline support 👀 May 19, 2020
@puchesjr
Copy link

Ah yes - I was thinking of this from a web perspective. But, you could use this https://rnfirebase.io/reference/firestore/settings for react-native :).

@nandorojo
Copy link
Owner Author

Good call! Unfortunately that library doesn’t support Expo without detaching, so it will only work for Bare expo projects. A pure-JS solution for managed Expo apps specifically is what I’m hoping to achieve

@nandorojo nandorojo changed the title [React Native] Add offline support 👀 [React Native/ Expo only] Add offline support 👀 Jun 18, 2020
@nandorojo
Copy link
Owner Author

Solved this with https://github.com/nandorojo/expo-firestore-offline-persistence. Turned it into its own package.

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

No branches or pull requests

2 participants