Comments (4)
Hello,
have you found the solution?
I'm also looking for how to disconnect.
from react-native-firebase.
So I saw a stack overflow saying I should use redux, then came across a documentation saying redux is ok for state, but not Navigation state.
I wrote a logout function as:
const onLogoutButtonPress = () => { // navigation.navigate('Login'); firebase .auth() .signOut() .then(() => { console.log("USER LOGGED IN !!!: " + JSON.stringify(user)) setUser(null) console.log("USER LOGGED OUT !!!: " + JSON.stringify(user)) // navigation.navigate('Login')} // navigation.navigate( // 'Home', // {}, // NavigationActions.navigate({ // routeName: 'HomeScreen' // }) // ) }) .catch(error => { alert(error) }) }
That logs out user, but doesnt re-render app.js which houses user auth logic.
I looked react navigation documentation, but to no avail. Maybe I missed something
Some sources say you can use NavigationActions , as navigation is not available for use as navigation.navigate('Login')}
That said I passed navigation as a prop and it was empty. Thats because navigation.navigate() is only available to navigate to pages within the stack.
In our case, HomeScreen is in one stack and Login + Registration is in another stack. So we cannot move up from stack to stack.
But I wonder if we put all of them in the same stack, then navigation.navigate() will work right and being a mobile app, the user wont be able to navigate to the page without a button provided by us ? ....hmmm this just came to me #rubberDuckTheory .. I will test and get back to you guys.
PS. I am not using redux for this, but might keep it in to manage other all round state bits.
If any one else gets a solution, do post #happyLockdownCoding
Mo
from react-native-firebase.
UPDATE:
So I did 2 things and I think it works.
It seems to now be logging out for me and loads the component as the Login and Registration components are now in the stack. By the time it calls that component firebase .signOut() has already run
So in effect, you wont be logged in anymore
Try and let me know
Hope this helps
@mrcflorian Thank you for this awesome repo. Will be good to hear your thoughts.
Sources: https://reactnavigation.org/docs/stack-actions/
from react-native-firebase.
this should work for any future googlers. setting setUser to null triggers a rerender and thus you to automatically go to the login screen, so there is no need to redirect explicitly (unless you wanted to make a "logged out" screen).
from react-native-firebase.
Related Issues (13)
- White screen on initial yarn ios HOT 7
- firebase repo is out of date HOT 5
- FirebaseError: [code=unavailable]: Failed to get document because the client is offline HOT 1
- need to change firebase config HOT 1
- expo build:android failed with error code 500
- firebase is not defined HOT 3
- Firebase crashing after installation HOT 1
- The action 'NAVIGATE' with payload {"name":"Home","params":{"user":{"email":"[email protected]","id":"xxx","fullName":"test"}}} was not handled by any navigator HOT 3
- The action 'NAVIGATE' with payload {"name":"Home","params":{"user":{"email":"[email protected]","id":"xxx","fullName":"test"}}} was not handled by any navigator #3 HOT 1
- Issue with navigation handler when navigate to a new screen HOT 9
- com.facebook.react.bridge.ReadableNativeMap cannot be cast to java.lang.string
- Component Exception Can't find variable: user
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-firebase.