Comments (6)
Hi @ssk-mps! Thank you!
And yes, you can achieve it with rn-navio
as it's fully built on React Navigation. Once you built your layout with const navio = Navio.build(...)
, you can generate <navio.Root />
component which takes two arguments initialRouteName
and navigationContainerProps
. The latter will be passed directly to NavigationContainer
. In your case, it's going to be something like <navio.Root navigationContainerProps={{linking: yourLinkings}} />
(as here, AppRoot == navio.Root).
from expo-starter.
That's awesome! Thanks for the pointer. It would be great to document this in the rn-navio
readme file.
What is the best way to get the RootStackParamList
that is generated by rn-navio
? Here is the code that I have:
import { LinkingOptions } from '@react-navigation/native';
import * as Linking from 'expo-linking';
import { RootStackParamList } from '../types';
const linking: LinkingOptions<RootStackParamList> = {
prefixes: [Linking.createURL('/')],
config: { ... }
}
and I've explicitly defined the type of RootStackParamList
as follows:
export type RootStackParamList = {
Root: NavigatorScreenParams<RootTabParamList> | undefined;
Modal: undefined;
NotFound: undefined;
};
from expo-starter.
hey @ssk-mps! Glad it helped! And definitely, I am collecting some feedback and feature requests that will be implemented in the next releases.
Could you elaborate more on that and give broader example with use cases? That would be helpful as I don't fully get it.
from expo-starter.
Hi @kanzitelli The use-case is pretty much TypeScript type safety. When I declare const linking = {...}
, then TS doesn't know what this object should be. But when I declare const linking: LinkingOptions<RootStackParamList> = { ... }
then TS can catch the problems in the linking. This is why LinkingOptions
type is exposed by @react-navigation/native
. I hope it helps
from expo-starter.
@ssk-mps ah okay, got it! so currently rn-navio
doesn't provide a type that describes the structure of the app, RootStackParamList
in your case. maybe I'll come up with something in the future. I will add it into README as well, but now you will need to define it yourself as you do. the structure that navio builds might look like this:
const navio = Navio.build({
screens: {
Main,
Settings,
Example,
Playground,
},
stacks: {
MainStack: ['Main', 'Example'],
ExampleModalStack: ['Example'],
},
tabs: {
MainTab: {
stack: 'MainStack',
},
PlaygroundTab: {
stack: ['Playground'],
},
SettingsTab: {
stack: ['Settings'],
},
},
modals: {
ExampleModal: 'ExampleModalStack',
},
root: 'Tabs', // 'Tabs' by default; takes also any stack name as a value
});
export type RootStackParamList = {
// tabs
Tabs: {
MainTab: {
Main: <props>,
Example: <props>,
},
PlaygroundTab: {
Playground: <props>,
},
SettingsTab: {
Settings: <props>,
},
},
// stacks, as you can .pushStack() as well
ExampleStack: {
Example: <props>
},
// modals
ExampleModal: {
Example: <props>
}
}
Hope it helps! And let me know how it works in your case :)
from expo-starter.
That works for me! Thanks @kanzitelli Please feel free to close this issue.
from expo-starter.
Related Issues (20)
- Mobx frozen Error HOT 3
- Changing the language or appearance crashes the app in release build HOT 2
- Camera indicator light remains on even when Camera is unmounted HOT 4
- "Store.name" creates duplicates once published HOT 3
- route props on options HOT 3
- TypeError: undefined is not an object (evaluating '_stores.stores.ui') HOT 6
- Update dependecies HOT 1
- Possible Unhandled Promise Rejection (id:0) HOT 1
- ApiV2Error: Entity Not Authorized HOT 3
- Hide tab bar for specific screen. HOT 9
- How to get route.params? HOT 1
- yarn start --web HOT 6
- Can I do auth flow like below? HOT 1
- upgrade to rnuilib v7 HOT 1
- How to pass variable to stack HOT 1
- Newbie questions (mmkv, auth) HOT 2
- Params doesn't seem to work. HOT 2
- How to pop to the first screen of the stack when the user presses the back button HOT 1
- expo production build error HOT 1
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 expo-starter.