Comments (4)
hey @ScreamZ! this is a nice idea. I think a great example app for this would be to rebuild the "realworld" app: https://github.com/gothinkster/realworld
if you want to work on doing this we'd be happy to help as you run into issues along the way. one of the harder parts of getting started on it is that there is currently no existing mobile implementation, so you might have to make some ui design decisions
from react-navigation.github.io.
I'll try to answer. I have a fairly complex app with multiple users of different roles and deep linking, and it does work with react-navigation. In your ROOT you need to load the app state to find out if a user is already logged in or not. That will influence your initial screen. In the render method of ROOT, you'll do something like
render() {
let initialScreenString = 'Anonymous';
if (hasValidCredentials) {
initialScreenString = 'Authenticated'
}
// construct the right navigation structure conditionally
const RootStack = constructInitialStack(initialScreenString);
return (
<RootStack
ref={NavigationService.setContainer}
onNavigationStateChange={trackScreenChange}
/>
);
}
}
Your navigation structure will be something like
const constructInitialStack = initialRouteName => {
return MainStack(initialRouteName);
};
const MainStack = initialRouteName =>
StackNavigator(
{
AnonymousStack: { screen: AnonymousStack,
navigationOptions: {
header: null,
},
},
AuthenticatedTab: { screen: AuthenticatedTab },
ModalScreenOne: { screen: ModalScreenOne },
ModalScreenOne: { screen: ModalScreenOne },
},
{
...commonStackStyles,
initialRouteName,
// headerMode: 'none', -> this would also affect the modal scenes and we do not want that
// thus every navigator screen (eg. AnonymousStack) in this navigator must define header: null
mode: 'modal',
}
);
const AnonymousStack = StackNavigator(
{
LoginScreen: { screen: LoginScreen },
OnboardingScreen: { screen: OnboardingScreen },
}
);
You will probably need to do some reset
s if you want to have some 'history' in your stack.
from react-navigation.github.io.
Hi,
OP has probably found a solution as I speak, but for future generations : this part of the docs explains the authentication flow very, very well 👍 https://reactnavigation.org/docs/en/auth-flow.html
If you get this right, building nested navigators on top of it will be a child's play.
cheers
from react-navigation.github.io.
@marcpicaud This was not set at the moment I wrote that topic, I think it's one of the consequence of this part of the documentation ;D
Regards
from react-navigation.github.io.
Related Issues (20)
- Error 404 when following Nesting Navigator hyperlink to expo Snack
- Stack navigator for each tab code example warning HOT 1
- Inconsistent TypeScript behavior with optional arguments in useNavigation
- Request for a sandbox environment for React Navigation
- Found screens with the same name nested inside one another HOT 2
- React Navigation logo has multiple control points
- In "Help" page witgh presentation set value to "transparentModal", I want push one new Page of name "Profile", How shuld i do?
- [email protected] -> Compiling JS failed .... invalid expression Buffer
- Improve/Update React-Navigation SVGs
- Remove 'make me a sandwich' references from documentation .mov
- Most of the react navigation examples on snack are not working HOT 2
- Use Deep Link, occur error
- React-native physical iOS devices not showing images
- NavigationContainer: initialRouteName: Issue with TypeScript
- Group Component Information HOT 2
- Nested navigation Snack Expample NOT FOUND
- Missing import on multiple-drawers
- Modal example issue - `RNSScreen` must be a function HOT 1
- Broken outbound URL HOT 1
- Remove mention of deprecated 'jest-native' in docs
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-navigation.github.io.