-
Notifications
You must be signed in to change notification settings - Fork 3
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
how to switch rootscreen #6
Comments
Hey @roycehe! Let's take this - https://github.com/kanzitelli/rnn-starter/blob/master/App.tsx - as an example. import {LogBox} from 'react-native';
import {Root, Screen, BottomTabs} from 'rnn-screens';
import {screens} from './src/screens';
import {Services} from './src/services';
import {Stores, stores} from './src/stores';
import {DesignSystem} from './src/utils/designSystem';
import SplashScreen from 'react-native-splash-screen';
LogBox.ignoreLogs(['Require', 'RCTBridge']);
export const beforeStart = async (): PVoid => {
// 1. hydrate stores
await Stores.hydrate();
// 2. configure design system
await DesignSystem.configure();
// 3. init services
await Services.init();
// 4. hide splash screen
SplashScreen.hide();
};
export const App = () =>
Root(
// we can use `stores` here as it was already inited in beforeStart functions
stores.auth.isLoggedIn ?
Screen(screens.get('Login')) :
BottomTabs([
Screen(screens.get('Main')),
Screen(screens.get('Playground')),
Screen(screens.get('Settings')),
]),
); I didn't test this code, but it seems like a working piece. |
This works when you launch the app. However, at least for me, the stores are not updating when state changes and the root stack never updates. |
1 check if has token or not before screens show
2 if token use main tab, not use loginscreen
3 switch to main tab after login
The text was updated successfully, but these errors were encountered: