I am using react native and i want to call a function in tabs
import {createBottomTabNavigator} from 'react-navigation-tabs';
const TabNavigator = createBottomTabNavigator(
{
Home:{
screen:CustomMapView,
navigationOptions:{
tabBarLabel:'Home',
tabBarIcon:({tintColor})=>(
<Image source = {require("../../Images/react-logo.png")} style={{width : 30 , height:30}}/>
)
}
}, Profile11:{
screen:Profile11,
navigationOptions:{
tabBarLabel:'Profile11',
tabBarIcon:({tintColor})=>(
<Image source = {require("../../Images/react-logo.png")} style={{width : 30 , height:30}}/>
)
}
},
Profile: {
screen:ProfileScreen,
navigationOptions:{
tabBarLabel:'Profile',
tabBarIcon:({tintColor})=>(
// <Icon name="ios-person" color={tintColor} size={25}/>
<Image source = {require("../../Images/react-logo.png")} style={{width : 30 , height:30}}/>
)
}
},
},
{
initialRouteName: "Home"
},
);
As i am using above i want to set some contions on tabs like home if condition true run set CustomMapView as the screen if condition false any other screen will set like CustomMapView.js
how can i do this
Check this example if you want to set a condition for rendering page:
const MainApp = createBottomTabNavigator(
{
Home: HomeTab ,
Settings: SettingsTab ,
},
{
defaultNavigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, horizontal, tintColor }) => {
const { routeName } = navigation.state;
if (routeName === 'Home') {
return (
<Image
source={ require('./assets/home.png') }
style={{ width: 20, height: 20, }} />
);
} else {
return (
<Image
source={ require('./assets/settings.png') }
style={{ width: 20, height: 20 }} />
);
}
},
}),
tabBarOptions: {
activeTintColor: '#FF6F00',
inactiveTintColor: '#263238',
},
});
And if you want to call a method on tab press, then refer this example :
Profile: {
screen:ProfileScreen,
navigationOptions:{
tabBarLabel:'Profile',
tabBarIcon:({tintColor})=>(
// <Icon name="ios-person" color={tintColor} size={25}/>
<Image source = {require("../../Images/react-logo.png")} style={{width : 30 , height:30}}/>
),
tabBarOnPress: () => { this.openGallery() }
}
},
Related
I'm following an tutorial and I got a little stuck.
I'm trying to add an custom icon in a react native tab navigator but I had not been lucky and hope some fellow member can guide me in the right direction.
import React from 'react';
import { createMaterialTopTabNavigator, Image} from 'react-navigation';
import FoldersList from '../screens/FoldersList';
const Routes = {
Home: {
screen: (props) => <FoldersList {...props} tabIndex={0}/>,
navigationOptions: {
title: 'Home'
}
},
MyNewTab: {
screen: (props) => <FoldersList {...props} tabIndex={1} createFolderTitle='Create new tab folder' />,
navigationOptions: {
title: 'MyNewTab'
}
},
MyThirdTab: {
screen: (props) => <FoldersList {...props} tabIndex={2} createFolderTitle='Create third tab folder'/>,
navigationOptions: {
tabBarIcon: ({ tintColor }) => {
return (<Image
style={{ width: 50, height: 50 }}
source={{ require: "../../images/AddFolder.png" }}/>);}
}
},
};
const routeConfig = {
swipeEnabled: false,
tabBarOptions: {
style: {
backgroundColor: '#013a65',
},
renderIndicator: () => null, // Indicatorline under tabbar
activeTintColor:'red',
inactiveTintColor:'#ffffff',
},
},
};
export default TabNavigator = createMaterialTopTabNavigator({
...Routes
}, routeConfig);
Hello here is a simple code:
UPDATE
class MyHomeScreen extends React.Component {
static navigationOptions = {
tabBarLabel: 'Home',
// Note: By default the icon is only shown on iOS. Search the showIcon
option below.
tabBarIcon: ({ tintColor }) => (
<Image
source={require('./chats-icon.png')}
style={[styles.icon, {tintColor: tintColor}]}
/>
),
};
render() {
return (
<Button
onPress={() => this.props.navigation.navigate('Notifications')}
title="Go to notifications"
/>
);
}
}
class MyNotificationsScreen extends React.Component {
static navigationOptions = {
tabBarLabel: 'Notifications',
tabBarIcon: ({ tintColor }) => (
<Image
source={require('./notif-icon.png')}
style={[styles.icon, {tintColor: tintColor}]}
/>
),
};
render() {
return (
<Button
onPress={() => this.props.navigation.goBack()}
title="Go back home"
/>
);
}
}
const styles = StyleSheet.create({
icon: {
width: 26,
height: 26,
},
});
const MyApp = TabNavigator({
Home: {
screen: MyHomeScreen,
},
Notifications: {
screen: MyNotificationsScreen,
},
}, {
tabBarPosition: 'top',
animationEnabled: true,
tabBarOptions: {
activeTintColor: '#e91e63',
},
});
According to the docs, the showIcon property is setted to false on Android ( https://web.archive.org/web/20171015002750/https://reactnavigation.org/docs/navigators/tab#tabBarOptions-for-TabBarTop-default-tab-bar-on-Android ).
IF THE ABOVE CODE DO NOT WORKS FOLLOW THE BELLOW STEPS:
const MyApp = TabNavigator({
Displayed: {
screen: MyHomeScreen,
navigationOptions: {
title: 'Favorites',
tabBar: {
icon: ({tintColor}) => (<Image
source={require('./chats-icon.png')}
style={{width: 26, height: 26, tintColor: tintColor}}
/>)
},
},
},
...
or
class MyHomeScreen extends React.Component {
static navigationOptions = {
title: 'Foo Bar',
tabBar: {
icon: ({ tintColor }) => (
<Image
source={require('./chats-icon.png')}
style={{width: 26, height: 26, tintColor: tintColor}}
/>
),
}
};
...
I really hope that some code help you...
if you until do not work if the codes bellow, please see this other code:
UPDATE
//Package json
//change "react-navigation-material-bottom-tabs": "0.1.2"
import React, {Component} from 'react';
import {View,
Text,
StyleSheet,
//use SafeAreaView to move the images away from the top of the phone
SafeAreaView,
Image} from 'react-native';
import {createMaterialBottomTabNavigator} from 'react-navigation-material-bottom-tabs';
import {createMaterialTopTabNavigator} from 'react-navigation'
//imports the icons
import Icon from 'react-native-vector-icons/Ionicons'
export default class App extends Component{
render(){
return(
<SafeAreaView style = {{ flex: 1, backgroundColor: '#f2f2f2'}} >
<AppTabNavigator/>
</SafeAreaView>
)
}
}
//homescreen and the text that is displayed on that page
class HomeScreen extends Component {
render() {
return(
<View style = {styles.container}>
<Text>Welcome to my Navigator! </Text>
</View>
);
}
}
//MyPage and the text that is displayed on that page
class MyPage extends Component {
render() {
return(
<View style = {styles.container}>
<Text>My Page </Text>
</View>
);
}
}
//settings and the text that is displayed on that page
class SettingsScreen extends Component {
render() {
return(
<View style = {styles.container}>
<Text>Settings </Text>
</View>
);
}
}
//settings and the text that is displayed on that page
class ProfileScreen extends Component {
render() {
return(
<View style = {styles.container}>
<Text>Profile </Text>
</View>
);
}
}
//ceated a topTabNavigator then moved the buttons to the bottom
const AppTabNavigator = createMaterialTopTabNavigator({
Home: {
screen: HomeScreen,
navigationOptions: {
tabBarLabel: 'Home',
tabBarIcon: ({tintColor}) => (
<Icon name="ios-home" color = {tintColor} size = {24}/>
)
}
},
Settings: {
screen: SettingsScreen,
navigationOptions: {
tabBarLabel: 'Settings',
tabBarIcon: ({tintColor}) => (
<Icon name="ios-settings" color = {tintColor} size = {24}/>
)
}
},
Profile: {
screen: ProfileScreen,
navigationOptions: {
tabBarLabel: 'Profile',
tabBarIcon: ({tintColor}) => (
// <Icon name="ios-profile" color = {tintColor} size = {24}/>
<Image
source={require('./assets/snack-icon.png')}
style={{
marginLeft: 1,
marginTop: 1,
width: 25,
height: 25,
tintColor: '#FF3D00',
}}
/>
)
}
},
MyPage: {
screen: MyPage,
navigationOptions: {
tabBarLabel: 'Page',
tabBarIcon: ({tintColor}) => (
<Icon name = "ios-body" color = {tintColor} size = {24} />
)
}
}
},
{
//starts the program on Home Screen
initialRouteName: 'Home',
//orders the screens
//order: ['Settings', 'Home'],
//puts a color when that screen is activated in the tabs
//activeTintColor: 'white',
//Allows for icons(only) to appear on inactive tabs when you have more than 3 tabs
shifting: true,
tabBarPosition: 'top',
// swipeEnabled: true,
// animationEnabled: false,
tabBarOptions: {
activeTintColor: 'red',
inactiveTintColor: 'grey',
style: {
backgroundColor: 'pink',
borderTopWidth: 0.5,
borderTopColor: 'grey'
},
// indicatorStyle: {
// height: 0
// },
showIcon: true
}
})
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
}
});
the code to help you is this:
Profile: {
screen: ProfileScreen,
navigationOptions: {
tabBarLabel: 'Profile',
tabBarIcon: ({tintColor}) => (
// <Icon name="ios-profile" color = {tintColor} size = {24}/>
<Image
source={require('./assets/snack-icon.png')}
style={{
marginLeft: 1,
marginTop: 1,
width: 25,
height: 25,
tintColor: '#FF3D00',
}}
/>
)
}
},
import React from "react";
import { Image } from "react-native";
import { createMaterialTopTabNavigator } from "react-navigation-tabs";
import { createAppContainer } from "react-navigation";
import Profile from "../components/Profile/Profile";
import Trips from "../components/Trips/MyTrips";
import Wallet from "../components/Wallet/Wallet";
import Booking from "../components/Booking/Booking";
import Summary from "../components/Summary/Summary";
import Colors from "../Shared/Colors";
bottomBarConfig = {
Summary: {
screen: Summary,
navigationOptions: {
tabBarIcon: ({ focused }) => {
return (
<Image
source={
focused
? require("./../assets/images/home_active.png")
: require("./../assets/images/home_notactive.png")
}
size={25}
color={focused ? Colors.Primary : "#808080"}
/>
);
},
title: "Home"
}
},
Trips: {
screen: Trips,
navigationOptions: {
tabBarIcon: ({ focused }) => {
return (
<Image
source={
focused
? require("./../assets/images/mytrips_active.png")
: require("./../assets/images/mytrips_notactive.png")
}
size={25}
color={focused ? Colors.Primary : "#808080"}
/>
);
},
style: {}
}
},
Booking: {
screen: () => null,
navigationOptions: {
tabBarIcon: ({ focused }) => {
return (
<Image
source={require("./../assets/images/book.png")}
size={55}
style={{ height: 120 }}
color={focused ? Colors.Primary : "#808080"}
/>
);
},
showLabel: false,
gesturesEnabled: false
}
},
Wallet: {
screen: Wallet,
navigationOptions: {
tabBarIcon: ({ focused }) => {
return (
<Image
source={
focused
? require("./../assets/images/mywallet_active.png")
: require("./../assets/images/mywallet_notactive.png")
}
size={25}
color={focused ? Colors.Primary : "#808080"}
/>
);
}
}
},
Profile: {
screen: Profile,
navigationOptions: {
tabBarIcon: ({ focused }) => {
return (
<Image
source={
focused
? require("./../assets/images/more_active.png")
: require("./../assets/images/more_notactive.png")
}
size={25}
color={focused ? Colors.Primary : "#ff00ff"}
/>
);
}
}
}
};
const TabNavigator = createMaterialTopTabNavigator(bottomBarConfig, {
tabBarPosition: "bottom",
tabBarOptions: {
showIcon: true,
upperCaseLabel: false,
activeTintColor: Colors.Primary,
inactiveTintColor: "gray",
pressColor: Colors.Primary,
style: {
backgroundColor: "white",
border: "none"
},
labelStyle: {
fontSize: 10,
fontFamily: "Montserrat-Regular"
},
indicatorStyle: {
backgroundColor: Colors.Primary
}
}
});
const App = createAppContainer(TabNavigator);
export default App;
This is a photo of what I want to execute(not what I have right now), bottom bar with big button in the middle.
For that I created screen for it and I will remove the label and style the image. But the problem I want user when swipes from tab 2 to tab 3 he actually goes to tab 4 not 3. I want this button to take user to another route.
So I want tab 3 to be skippable, no screen for it, I want it as just a button.
I am using create createMaterialTopTabNavigator because it has swipe feature and I already configured it to be positioned in bottom and I will be editing style of button in middle, just need to make skippable.
I am trying to create a new app. I have created the side menu. But side menu drawer not working if i am in the same screen.For example in the screenshot i am already in the home screen. Now if i click the home in the side menu there is no action. One more question now the side menu covers the whole screen height. I want to be display between the header and bottom tab navigator. Please help me image
const DashboardTabNavigator = createBottomTabNavigator( {
Home: HomeScreen,
WebMenu: WebMenuScreen,
Settings: SettingsScreen,
},
{
tabBarOptions: {
activeTintColor: 'tomato',
inactiveTintColor: 'gray',
labelStyle: {
fontSize: 15
},
tabStyle: {
justifyContent: 'center'
},
showIcon: false
},
});
//MenuDrawer
export class MenuDrawer extends React.Component {
gotoHome = () => {
this.props.navigation.navigate('Home');
}
gotoWebMenu = () => {
this.props.navigation.navigate('WebMenu');
}
gotoSettings = () => {
this.props.navigation.navigate('Settings');
}
render() {
return(
<View style = {styles.container}>
<Text onPress={this.gotoHome} style = {styles.item} ><Ionicons name="md-home" size={20} /> Home</Text>
<Text onPress={this.gotoWebMenu} style = {styles.item} ><Ionicons name="logo-rss" size={20} /> Web Menu</Text>
<Text onPress={this.gotoSettings} style = {styles.item} ><Ionicons name="md-settings" size={20} /> Settings</Text>
</View>
)
}
}
//side menu
const MyApp = createDrawerNavigator({
Menu: {
screen: DashboardTabNavigator,
},
},
{
contentComponent: MenuDrawer,
drawerPosition: 'right',
drawerWidth:width - width/2
},
{
initialRouteName: 'Login'
});
//screen route
const LoginStack = createStackNavigator({
Login: {
screen: Login
},
Home:{ screen: MyApp},
}, {
initialRouteName: 'Login',
headerMode: 'null'
});
const MyApp1 = createAppContainer(LoginStack);
Try this.
class NavigationDrawerStructure extends Component {
toggleDrawer = () => {
//Props to open/close the drawer
this.props.navigationProps.toggleDrawer();
};
render() {
return (
<View style={{ flexDirection: 'row' }}>
<TouchableOpacity onPress={this.toggleDrawer.bind(this)}>
<Image
source={require('../Img/hamburger.png')}
style={{ width: 25, height: 25, marginLeft: 20, tintColor: '#ffffff' }}
/>
</TouchableOpacity>
</View>
);
}
}
And then use it in this way
const HomeActivity_StackNavigator = createStackNavigator({
Home: {
screen: Main,
navigationOptions: ({ navigation }) => ({
title: 'Dashboard',
headerLeft: <NavigationDrawerStructure navigationProps={navigation} />,
headerStyle: {
backgroundColor: '#FF9800'
},
headerTintColor: '#fff'
}),
},
}, {headerLayoutPreset: 'center'});
I have a createBottomTabNavigator on my project.by default tabs have specific height and bottom position .
how can I change position and height of it
my code:
const Navigate=createBottomTabNavigator({
Home:{screen:Home,navigationOptions:{
tabBarLabel:'Home',
tabBarIcon:({tintColor})=>(
<Icon name="md-home" color={tintColor} size={25}/>
)
} },
Camera:{screen:Camera,navigationOptions:{
tabBarLabel:'Profile',
tabBarIcon:({tintColor})=>(
<Icon name="md-add-circle" color={tintColor} size={25}/>
)
} },
Profile: {
screen:Profile,
navigationOptions:{
tabBarLabel:'Profile',
tabBarIcon:({tintColor})=>(
<Icon name="md-person" color={tintColor} size={25}/>
)
}
},
}
,{
tabBarOptions: {
activeTintColor: 'red',
inactiveTintColor: 'cyan',
activeBackgroundColor:'lightgreen',
showLabel:false,
keyboardHidesTabBar:false,
tabStyle:{
backgroundColor:'orange',
height:40,
},
},
},
},
);
export default createAppContainer(Navigate);
You need to set the height in the style object, not the tabBarOptions.
Refer to https://reactnavigation.org/docs/en/bottom-tab-navigator.html for the styles object.
I did it like this in my app
const navigatorConfig = {
defaultNavigationOptions: ({ navigation }) => ({
tabBarIcon: ({ tintColor }) => {
switch (routeName) {
....
}
style: {
height: responsiveHeight(7.5),
borderTopWidth: 0,
},
}}
enter code here
I am using react-navigation and as per the structure of my application, we have a tab navigator inside stack navigator, I am not been able to find any proper guide for implementing Deep-Linking.
https://v1.reactnavigation.org/docs/deep-linking.html. this doesn't give any reference for nested navigators.
You have to basically pass a path to every upper route untill you come to you nested route. This is indipendent of the type of navigator you use.
const HomeStack = createStackNavigator({
Article: {
screen: ArticleScreen,
path: 'article',
},
});
const SimpleApp = createAppContainer(createBottomTabNavigator({
Home: {
screen: HomeStack,
path: 'home',
},
}));
const prefix = Platform.OS == 'android' ? 'myapp://myapp/' : 'myapp://';
const MainApp = () => <SimpleApp uriPrefix={prefix} />;
In this case to route to an inner Navigator this is the route: myapp://home/article.
This example is using react-navigation#^3.0.0, but is easy to transfer to v1.
So, after the arrival of V3 of react navigation, things got extremely stable. Now i will present you a navigation structure with deep-linking in a Switch navigator -> drawerNavigator-> tabNavigator -> stack-> navigator. Please go step by step and understand the structure and keep referring to official documentation at everystep
With nested navigators people generally mean navigation structure which consists of drawer navigator, tab navigator and stackNavigator. In V3 we have SwitchNavigator too. So let's just get to the code,
//here we will have the basic React and react native imports which depends on what you want to render
import React, { Component } from "react";
import {
Platform,
StyleSheet,
Text,
View, Animated, Easing, Image,
Button,
TouchableOpacity, TextInput, SafeAreaView, FlatList, Vibration, ActivityIndicator, PermissionsAndroid, Linking
} from "react-native";
import { createSwitchNavigator, createAppContainer, createDrawerNavigator, createBottomTabNavigator, createStackNavigator } from "react-navigation";
export default class App extends Component<Props> {
constructor() {
super()
this.state = {
isLoading: true
}
}
render() {
return <AppContainer uriPrefix={prefix} />;
}
}
class WelcomeScreen extends Component {
state = {
fadeAnim: new Animated.Value(0.2), // Initial value for opacity: 0
}
componentDidMount() {
Animated.timing( // Animate over time
this.state.fadeAnim, // The animated value to drive
{
toValue: 1,
easing: Easing.back(), // Animate to opacity: 1 (opaque)
duration: 1000,
useNativeDriver: true // Make it take a while
}
).start(); // Starts the animation
}
render() {
let { fadeAnim } = this.state;
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center", backgroundColor: '#000' }}>
<Animated.View // Special animatable View
style={{ opacity: fadeAnim }}
>
<TouchableOpacity
onPress={() => this.props.navigation.navigate("Dashboard")}
style={{
backgroundColor: "orange",
alignItems: "center",
justifyContent: "center",
height: 30,
width: 100,
borderRadius: 10,
borderColor: "#ccc",
borderWidth: 2,
marginBottom: 10
}}
>
<Text>Login</Text>
</TouchableOpacity>
</Animated.View>
<Animated.View // Special animatable View
style={{ opacity: fadeAnim }}
>
<TouchableOpacity
onPress={() => alert("buttonPressed")}
style={{
backgroundColor: "orange",
alignItems: "center",
justifyContent: "center",
height: 30,
width: 100,
borderRadius: 10,
borderColor: "#ccc",
borderWidth: 2
}}
>
<Text> Sign Up</Text>
</TouchableOpacity>
</Animated.View>
</View>
);
}
}
class Feed extends Component {
render() {
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Button
onPress={() => this.props.navigation.navigate("DetailsScreen")}
title="Go to details"
/>
</View>
);
}
}
class Profile extends Component {
render() {
return (
<SafeAreaView style={{ flex: 1, }}>
//Somecode
</SafeAreaView>
);
}
}
class Settings extends Component {
render() {
return (
<View style={{ flex: 1 }}>
//Some code
</View>
);
}
}
const feedStack = createStackNavigator({
Feed: {
screen: Feed,
path: 'feed',
navigationOptions: ({ navigation }) => {
return {
headerTitle: "Feed",
headerLeft: (
<Icon
style={{ paddingLeft: 10 }}
name="md-menu"
size={30}
onPress={() => navigation.openDrawer()}
/>
)
};
}
},
DetailsScreen: {
screen: Detail,
path: 'details',
navigationOptions: ({ navigation }) => {
return {
headerTitle: "Details",
};
}
}
});
const profileStack = createStackNavigator({
Profile: {
screen: Profile,
path: 'profile',
navigationOptions: ({ navigation }) => {
return {
headerTitle: "Profile",
headerMode: 'Float',
headerLeft: (
<Icon
style={{ paddingLeft: 10 }}
name="md-menu"
size={30}
onPress={() => navigation.openDrawer()}
/>
)
};
}
},
DetailsScreen: {
screen: Detail,
path: 'details',
navigationOptions: ({ navigation }) => {
return {
headerTitle: "Details"
};
}
}
});
const settingStack = createStackNavigator({
Settings: {
screen: Settings,
path: 'settings',
navigationOptions: ({ navigation }) => {
return {
headerTitle: "Settings",
headerLeft: (
<Icon
style={{ paddingLeft: 10 }}
name="md-menu"
size={30}
onPress={() => navigation.openDrawer()}
/>
)
};
}
},
DetailsScreen: {
screen: Detail,
path: 'details',
navigationOptions: ({ navigation }) => {
return {
headerTitle: "Details"
};
},
}
});
const DashboardTabNavigator = createBottomTabNavigator(
{
feedStack: {
screen: feedStack,
path: 'feedStack',
navigationOptions: ({ navigation }) => {
let tabBarVisible = true;
if (navigation.state.index > 0) {
tabBarVisible = false;
}
return {
tabBarLabel: "Feed",
tabBarVisible,
//iconName :`ios-list${focused ? '' : '-outline'}`,
tabBarIcon: ({ tintColor }) => (
<Icon name="ios-list" color={tintColor} size={25} />
)
};
}
},
profileStack: {
screen: profileStack,
path: 'profileStack',
navigationOptions: ({ navigation, focused }) => {
let tabBarVisible = true;
if (navigation.state.index > 0) {
tabBarVisible = false
}
return {
tabBarVisible,
tabBarLabel: "Profile",
tabBarIcon: ({ tintColor }) => (
<Icon name="ios-man" color={tintColor} size={25} />
)
};
// focused:true,
}
},
settingStack: {
screen: settingStack,
path: 'settingsStack',
navigationOptions: ({ navigation }) => {
let tabBarVisible = true;
if (navigation.state.index > 0) {
tabBarVisible = false;
}
return {
tabBarVisible,
tabBarLabel: "Settings",
tabBarIcon: ({ tintColor }) => (
<Icon name="ios-options" color={tintColor} size={25} />
)
}
}
},
},
{
navigationOptions: ({ navigation }) => {
const { routeName } = navigation.state.routes[navigation.state.index];
return {
// headerTitle: routeName,
header: null
};
},
tabBarOptions: {
//showLabel: true, // hide labels
activeTintColor: "orange", // active icon color
inactiveTintColor: "#586589" // inactive icon color
//activeBackgroundColor:'#32a1fe',
}
}
);
const DashboardStackNavigator = createStackNavigator(
{
DashboardTabNavigator: {
screen: DashboardTabNavigator,
path: 'dashboardtabs'
},
DetailsScreen: {
screen: Detail,
path: 'details',
navigationOptions: ({ navigation }) => {
return {
headerTitle: "Details"
};
}
}
},
{
defaultNavigationOptions: ({ navigation }) => {
return {
headerLeft: (
<Icon
style={{ paddingLeft: 10 }}
name="md-menu"
size={30}
onPress={() => navigation.openDrawer()}
/>
)
};
}
}
);
const AppDrawerNavigator = createDrawerNavigator({
Dashboard: {
screen: DashboardStackNavigator,
path: 'welcome'
},
DetailsScreen: {
screen: Detail,
path: 'friends',
navigationOptions: ({ navigation }) => {
return {
headerTitle: "Details",
};
}
}
});
//Switch navigator , will be first to load
const AppSwitchNavigator = createSwitchNavigator({
Welcome: {
screen: WelcomeScreen,
},
Dashboard: {
screen: AppDrawerNavigator,
path: 'welcome'
}
});
const prefix = 'myapp://';
const AppContainer = createAppContainer(AppSwitchNavigator);
For the process to setup React-navigation deep-linking please follow the official documentation
DetailsScreen was in my different folder and that will have class component of your choice
To launch the App the deep-link URL is myapp://welcome
To go to root page the deep-link URL is myapp://welcome/welcome
(this will reach at first page of first tab of tab navigator)
To go to any particular screen of tab navigator (suppose details
screen in profile tab) -
myapp://welcome/welcome/profileStack/details
const config = {
Tabs: {
screens: {
UserProfile: {
path: 'share//user_share/:userId',
parse: {
userId: (userId) => `${userId}`,
},
},
},
},
};
const linking = {
prefixes: ['recreative://'],
config,
};
if you have a screen in tab navigator you can do it like this via react-navigation v5