Comments (2)
Hey @roycehe! Let's take this - https://github.com/kanzitelli/rnn-starter/blob/master/App.tsx - as an example.
Say, we have stores.auth
where you store your auth state. You can use it in App
function to determine which root you want to use first. Then from Login screen, you will need to setRoot
manually to show your tabs.
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.
from rnn-screens.
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.
from rnn-screens.
Related Issues (8)
- Bottom Tab Style HOT 10
- How to implement a loading screen or swap root? HOT 1
- Best practice for adding global components HOT 1
- how to show overlayScreen? HOT 6
- Not working since last version
- setRoot causes Error: Invariant Violation: "Screen" has not been registered. HOT 1
- how to apply providers to specific screens only ?
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 rnn-screens.