react native navigation move between screens - react-native

I'm working with the latest react native navigation and trying to get to the next screen from my icon. Having no luck. I've tried to pass a function into my code and i'm getting no where. I know this is simple, i may just be mising one simple snippet to get this done. Please see below. Does anyone know how to properly write the navigation.
My issue is with the Stack Screen "ProductOverViewScreen".
import * as React from 'react';
import { createStackNavigator, createAppContainer } from '#react-navigation/stack';
import { NavigationContainer } from '#react-navigation/native';
import { HeaderButtons, Item } from 'react-navigation-header-buttons';
import 'react-native-gesture-handler';
import { Platform, Button } from 'react-native';
import { Ionicons } from '#expo/vector-icons';
import ProductsOverViewScreen from '../screens/shop/ProductOverViewScreen';
import ProductDetailScreen from '../screens/shop/ProductDetailScreen';
import CartScreen from '../screens/shop/CartScreen';
import Color from '../constants/Color';
import HeaderButton from '../components/UI/HeaderButton';
const Stack = createStackNavigator();
const newScreen = ({navigation}) => {
navigation.navigate('CartScreen');
}
function ShopNavigator(){
return(
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerStyle: {
backgroundColor: Platform.OS === 'android' ? Color.primary : ''
},
headerTitleStyle: {
fontFamily: 'open-sans-bold'
},
headerBackTitleStyle: {
fontFamily: 'open-sans'
},
headerTintColor: Platform.OS === 'android' ? 'white' : Color.primary,
}}
>
<Stack.Screen
name="ProductsOverViewScreen"
component={ProductsOverViewScreen}
options={{
headerRight: ({ navigation}) => (
<Button
onPress={() => navigation.navigate('CartScreen')}
title="Cart"
color='black'
/>
),
}}
/>
<Stack.Screen
name="ProductDetailScreen"
component={ProductDetailScreen}
options={({route}) => ({title: route.params.productTitle})}
/>
<Stack.Screen
name="CartScreen"
component={CartScreen}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
export default ShopNavigator;

I figured it out. hope this helps someone else out. Add the navigation within options like below.
options={({navigation, route}) => ({
headerRight: () => {
return (
<TouchableHighlight onPress={() => {navigation.navigate('CartScreen')}}>
<Text>Test</Text>
</TouchableHighlight>
);
}
})}
/>

Related

can not read property 'openDrawer' of undefined

i started to learn react native and i am getting error because i cant use openDrawer and i don't know where is the error.
i tried to follow the instructions on the react navigation web page.
below is my code
MainHeader
import React from 'react';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from '../../utils/Icon';
import {View} from 'react-native';
import {spacing} from '../../constants/theme';
const MainHeader = ({navigation}) => {
const insets = useSafeAreaInsets();
return (
<View
style={{
flexDirection: 'row',
justifyContent: 'space-between',
alignContent: 'center',
paddingHorizontal: spacing.l,
marginTop: insets.top,
}}>
<Icon icon="Hamburger" onPress={() => navigation.openDrawer()} />
<Icon style={{width: 25, height: 25}} icon="Cart" onPress={() => {}} />
</View>
);
};
export default MainHeader;
MainNavigator
import React from 'react';
import {createStackNavigator} from '#react-navigation/stack';
import {NavigationContainer} from '#react-navigation/native';
import {StatusBar} from 'react-native';
import TabNavigator from './TabNavigator';
const Stack = createStackNavigator();
const MainNavigator = () => {
return (
<NavigationContainer>
<StatusBar hidden />
<Stack.Navigator>
<Stack.Screen
name="Root"
component={TabNavigator}
options={{
headerShown: false,
useNativeDriver: true,
gestureEnabled: false,
}}
/>
</Stack.Navigator>
</NavigationContainer>
);
};
export default MainNavigator;
TabNavigator
import React from 'react';
import {createBottomTabNavigator} from '#react-navigation/bottom-tabs';
import {Animated} from 'react-native';
import Icon from '../utils/Icon';
import {colors, sizes} from '../constants/theme';
import PromoScreen from '../screens/PromoScreen';
import HomeNavigator from './HomeNavigator';
import ProductNavigator from './ProductNavigator';
import SearchNavigator from './SearchNavigator';
import ProfileNavigator from './ProfileNavigator';
import LoginScreen from '../screens/LoginScreen';
const tabs = [
{
name: 'Home',
screen: HomeNavigator,
},
{
name: 'Coffee',
screen: ProductNavigator,
},
{
name: 'Search',
screen: SearchNavigator,
},
{
name: 'Gift',
screen: PromoScreen,
},
{
name: 'Profile',
screen: LoginScreen,
},
];
const Tab = createBottomTabNavigator();
const TabNavigator = () => {
const offsetAnimation = React.useRef(new Animated.Value(0)).current;
return (
<>
<Tab.Navigator
initialRouteName="Home"
screenOptions={{
headerShown: false,
tabBarShowLabel: false,
}}>
{tabs.map(({name, screen}, index) => {
return (
<Tab.Screen
key={name}
name={name}
component={screen}
options={{
tabBarIcon: ({focused}) => {
return (
<Icon
icon={name}
size={40}
style={{
tintColor: focused ? colors.mainColor : colors.gray,
}}
/>
);
},
}}
listeners={{
focus: () => {
Animated.spring(offsetAnimation, {
toValue: index * (sizes.width / tabs.length),
useNativeDriver: true,
}).start();
},
}}
/>
);
})}
</Tab.Navigator>
</>
);
};
export default TabNavigator;
DrawNavigator
import React from 'react';
import {createDrawerNavigator} from '#react-navigation/drawer';
import {NavigationContainer} from '#react-navigation/native';
import HomeNavigator from './HomeNavigator';
const Drawer = createDrawerNavigator();
const MainDrawNavigator = () => {
return (
<NavigationContainer>
<Drawer.Navigator initialRouteName="Home">
<Drawer.Screen name="Home" component={HomeNavigator} />
</Drawer.Navigator>
</NavigationContainer>
);
};
export default MainDrawNavigator;
Home Navigator
import React from 'react';
import {createSharedElementStackNavigator} from 'react-navigation-shared-element';
import HomeScreen from '../screens/HomeScreen';
const Stack = createSharedElementStackNavigator();
const HomeNavigator = () => {
return (
<Stack.Navigator>
<Stack.Screen
name="HomeScreen"
component={HomeScreen}
options={{
headerShown: false,
useNativeDriver: true,
gestureEnabled: false,
}}
/>
</Stack.Navigator>
);
};
export default HomeNavigator;
HomeScreen
import React from 'react';
import {ScrollView, View} from 'react-native';
import MainHeader from '../components/Header/MainHeader';
import TitleHeader from '../components/Header/TitleHeader';
import MenuSlider from '../components/Home/MenuSlider';
import {Top_Sell, POPULAR} from '../data';
import SectionHeader from '../components/Header/SectionHeader';
import PopularList from '../components/Home/PopularList';
const HomeScreen = () => {
return (
<View style={{flex: 1, backgroundColor: '#fbfbfb'}}>
<MainHeader />
<TitleHeader mainTitle="Gợi ý" secondTitle="cho bạn" />
<ScrollView showsVerticalScrollIndicator={false}>
<MenuSlider list={Top_Sell} />
<SectionHeader title="Phổ biến" buttonTitle="More" onPress={() => {}} />
<PopularList list={POPULAR} />
</ScrollView>
</View>
);
};
export default HomeScreen;
I have tried several ways on stackOverflow but it doesn't work
You need to pass the navigation prop from HomeScreen to MainHeader to use it. Try replacing your HomeScreen with this:
const HomeScreen = ({ navigation }) => {
return (
<View style={{flex: 1, backgroundColor: '#fbfbfb'}}>
<MainHeader navigation={navigation} />
<TitleHeader mainTitle="Gợi ý" secondTitle="cho bạn" />
<ScrollView showsVerticalScrollIndicator={false}>
<MenuSlider list={Top_Sell} />
<SectionHeader title="Phổ biến" buttonTitle="More" onPress={() => {}} />
<PopularList list={POPULAR} />
</ScrollView>
</View>
);
};
please try this one. it seems that there is some issue with navigation state. check this one it will work.
based on your comment you may forgot to install some packages that are mandatory without that navigation won't work properly.
Please check for these.
#react-navigation/drawer,
#react-navigation/native-stack,
react-native-gesture-handler,
react-native-screens,
react-native-pager-view
[react-native-reanimated][1]
first configure these library , clean your project, delete it from device , rebuild and cheers!!
then. try this one
import React from 'react';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
import Icon from '../../utils/Icon';
import {View} from 'react-native';
import {spacing} from '../../constants/theme';
import { useNavigation } from '#react-navigation/native';
const MainHeader = ({}) => {
const navigation = useNavigation();
const insets = useSafeAreaInsets();
return (
<View
style={{
flexDirection: 'row',
justifyContent: 'space-between',
alignContent: 'center',
paddingHorizontal: spacing.l,
marginTop: insets.top,
}}>
<Icon icon="Hamburger" onPress={() => navigation.openDrawer()} />
<Icon style={{width: 25, height: 25}} icon="Cart" onPress={() => {}} />
</View>
);
};
export default MainHeader;

react native navigation.navigate is not working in nested navigator

//Here is my App.js file
import React, {Suspense} from 'react';
import {
SafeAreaView,
Text,
View,
Button,
Image,
TouchableOpacity,
} from 'react-native';
import {
NavigationContainer,
getFocusedRouteNameFromRoute,
} from '#react-navigation/native';
import {createStackNavigator} from '#react-navigation/stack';
import {createDrawerNavigator} from '#react-navigation/drawer';
import DrawerNavigator from './navigation/DrawerNavigator';
const SinginScreens = React.lazy(() => import('./screens/Login/SinginScreens'));
const Billing = React.lazy(() => import('./screens/Home/Billing'));
const Stack = createStackNavigator();
const Drawer = createDrawerNavigator();
const Loading = () => {
return <SafeAreaView>{/* <Text>Loading</Text> */}</SafeAreaView>;
};
const Routes = ({navigation}) => {
return (
<NavigationContainer>
<Stack.Navigator
initialRouteName={'Main'}>
<Stack.Screen
name={'Main'}
component={DrawerNavigator}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name="Billing"
component={Billing}
options={{
headerLeft: null,
headerShown: false,
}}
/>
<Stack.Screen
name="SinginScreen"
component={SinginScreens}
options={{
headerShown: false,
gestureEnabled: false,
}}
/>
</Stack.Navigator>
</NavigationContainer>
);
};
class App extends React.PureComponent {
render() {
return (
<Suspense fallback={<Loading />}>
<Routes />
</Suspense>
);
}
}
export default App;
//Here is my stack navigator
import React from 'react';
import {createStackNavigator} from '#react-navigation/stack';
import {Button} from 'react-native';
import {NavigationContainer} from '#react-navigation/native';
const Dashboard = React.lazy(() => import('../screens/Home/Dashboard.js'));
const Splash = React.lazy(() => import('../screens/Login/Splash'));
import {AuthContext} from './context';
const Stack = createStackNavigator();
const StackNavigator = ({route, navigation}) => {
return (
// <NavigationContainer>
<Stack.Navigator initialRouteName="Splash">
<Stack.Screen
name="Splash"
component={Splash}
options={{headerShown: false, gestureEnabled: false}}
/>
<Stack.Screen
name="Dashboard"
component={Dashboard}
options={{headerShown: false,}}
/>
</Stack.Navigator>
);
};
export default StackNavigator;
//Here is my drawer navigator
import React, {useState,useEffect} from 'react';
import {
createDrawerNavigator,
DrawerContentScrollView,
DrawerItemList,
DrawerItem,
} from '#react-navigation/drawer';
import {
SafeAreaView,
Text,
View,
Button,
Image,
TouchableOpacity,
StyleSheet,
} from 'react-native';
import {DrawerActions} from '#react-navigation/native';
import StackNavigator from './StackNavigator';
import { useNavigation } from '#react-navigation/native';
const Drawer = createDrawerNavigator()
const CustomDrawer = props => {
return (
<View style={{flex: 1}}>
<DrawerContentScrollView {...props}>
<DrawerItemList {...props} />
<DrawerItem
{...props}
label="Contacts"
labelStyle={styles.itemStyle}
icon={(focused, size, color) => (
<Image
style={{width: 25, height: 25}}
source={require('../assets/images/ic_contacts1.png')}
resizeMode="contain"
/>
)}
onPress={() => {
props.navigation.closeDrawer();
}}
/>
<DrawerItem
{...props}
label="POS Catalog"
labelStyle={styles.itemStyle}
icon={(focused, size, color) => (
<Image
style={{width: 25, height: 25}}
source={require('../assets/images/catalog.png')}
resizeMode="contain"
/>
)}
onPress={() => {
props.navigation.closeDrawer();
}}
/>
</DrawerContentScrollView>
</View>
);
};
const DrawerNavigator = () => {
return (
<Drawer.Navigator
drawerContent={props => <CustomDrawer {...props} />}
screenOptions={{
drawerPosition: 'right',
// drawerType:"permanent",
headerTintColor: '#000000',
headerTitleStyle: {
fontWeight: 'bold', //Set Header text style
},
}}>
<Drawer.Screen
name="Home"
component={StackNavigator}
options={{
drawerIcon: ({focused, size}) => (
<Ionicons name="ios-home-outline" size={size} color={'#000'} />
),
headerStyle: {
backgroundColor: 'white',
},
headerShown: false,
headerTintColor: 'black',
}}/>
</Drawer.Navigator>
);
};
export default DrawerNavigator;
I have drawer and stack navigator in my react native application.I have Screens called Splash,SigninScreen,Billing and Dashboard.
Screens in navigator
Splash,Dashboard- Stack Navigator
SigninScreen,Billing-App.js file(mentioned these screens out of drawer navigator to remove drawer for these screens)
What i want to achieve is when app is opening splash screen comes first and from splashscreen i am navigating to signinscreen using navigation.replace('SinginScreen') to avaoid back navigating to splash screen again when user clicks back button in 'SigninScreen'.
Similarly i am using navigation.replace('Billing') when navigating from SigninScreen to Billing to avoid back navigating to SigninScreen again when user clicks back button in Billing.
Now Inside Billing i am using navigation.navigate('Dashboard') to navigate from Billing to Dashboard page.Here i am facing error like The action 'NAVIGATE' with payload {"name":"Dashboard"} was not handled by any navigator.
Do you have a screen named 'Dashboard'?
Note:
I want to navigate to Dashboard page from Billing and also i don't want the user to go back again billing from Dashboard.

Is there a good way to set headerRight to pass onPress event in React Native

my friends, hope you doing well, I need some help with my React Native project.
I have the following code and struggling with the navigation for the "NewPost" screen.
I want to create a button in the header and handle press on it but can not figure out how to do it. Thanks for your precious help:
import React from 'react';
import 'react-native-gesture-handler';
import { TouchableOpacity } from 'react-native'
import { NavigationContainer } from '#react-navigation/native';
import { createStackNavigator } from '#react-navigation/stack';
import { Provider } from './src/context/BlogContext';
import IndexScreen from './src/screens/IndexScreen';
import CreatePost from './src/screens/CreatePost';
import ShowScreen from './src/screens/ShowScreen';
import { AntDesign } from '#expo/vector-icons'
const Stack = createStackNavigator()
const App = ({navigation}) => {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName='Index'>
<Stack.Screen name='Index'
component={IndexScreen}
options={{
title: 'Blogs',
headerRight: () => (
<TouchableOpacity onPress={() => navigation.navigate('NewPost')}>
<AntDesign name="plus" size={24} color="black" />
</TouchableOpacity>
)
}} />
<Stack.Screen name='ShowScreen' component={ShowScreen} options={{ title: 'Post Details' }} />
<Stack.Screen name='NewPost' component={CreatePost} options={{ title: 'Create a Post' }} />
</Stack.Navigator>
</NavigationContainer>
);
}
export default () => {
return (
<Provider>
<App />
</Provider>
)
}
First thing you cannot access navigation outside of the NavigationContainer so remove navigation from your App declaration :
const App = ({}) => { // remove navigation object from here
Now, to do user redirection on headerRight press, you can actually access naviagation on your headerRight and navigation user as below :
headerRight: ({navigation}) => (
<TouchableOpacity onPress={() => navigation.navigate('NewPost')}>
<AntDesign name="plus" size={24} color="black" />
</TouchableOpacity>
)
We can use useNavigation hook to implement the navigation In the navigator component.
For Example:
import React from 'react';
import 'react-native-gesture-handler';
import { TouchableOpacity } from 'react-native'
import { NavigationContainer, useNavigation } from '#react-navigation/native';
import { createStackNavigator } from '#react-navigation/stack';
import { Provider } from './src/context/BlogContext';
import IndexScreen from './src/screens/IndexScreen';
import CreatePost from './src/screens/CreatePost';
import ShowScreen from './src/screens/ShowScreen';
import { AntDesign } from '#expo/vector-icons'
const Stack = createStackNavigator()
const App = props => {
const navigation = useNavigation();
return (
<NavigationContainer>
<Stack.Navigator initialRouteName='Index'>
<Stack.Screen name='Index'
component={IndexScreen}
options={{
title: 'Blogs',
headerRight: () => (
<TouchableOpacity onPress={() => navigation.navigate('NewPost')}>
<AntDesign name="plus" size={24} color="black" />
</TouchableOpacity>
)
}} />
<Stack.Screen name='ShowScreen' component={ShowScreen} options={{ title: 'Post Details' }} />
<Stack.Screen name='NewPost' component={CreatePost} options={{ title: 'Create a Post' }} />
</Stack.Navigator>
</NavigationContainer>
);
}
export default () => {
return (
<Provider>
<App />
</Provider>
)
}
Here is the solution I got for my question:
options={({navigation}) => ({
title: 'Blogs',
headerRight: () => (
<TouchableOpacity onPress={() => navigation.navigate('NewPost')}>
import React from 'react';
import 'react-native-gesture-handler';
import { TouchableOpacity } from 'react-native'
import { NavigationContainer } from '#react-navigation/native';
import { createStackNavigator } from '#react-navigation/stack';
import { Provider } from './src/context/BlogContext';
import IndexScreen from './src/screens/IndexScreen';
import CreatePost from './src/screens/CreatePost';
import ShowScreen from './src/screens/ShowScreen';
import { AntDesign } from '#expo/vector-icons'
const Stack = createStackNavigator()
const App = () => {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName='Index'>
<Stack.Screen name='Index'
component={IndexScreen}
options={({navigation}) => ({
title: 'Blogs',
headerRight: () => (
<TouchableOpacity onPress={() => navigation.navigate('NewPost')}>
<AntDesign name="plus" size={24} color="black" />
</TouchableOpacity>
)
})} />
<Stack.Screen name='ShowScreen' component={ShowScreen} options={{ title: 'Post Details' }} />
<Stack.Screen name='NewPost' component={CreatePost} options={{ title: 'Create a Post' }} />
</Stack.Navigator>
</NavigationContainer>
);
}
export default () => {
return (
<Provider>
<App />
</Provider>
)
}

React Navigation Nested No Route Params v5

I can't seem to get any route params in my nested navigator. The params are present in the parent navigator, but they are not reachable in the child navigator.
So the child navigator does render the correct screen, but it does not have any params in the route (namely a category or product id).
It feels like I am misusing some syntax, but I can't quite figure out which one. Here is the stack of code, edited down a bit to make it easier to read.
Snack on Expo
Thank you.
Note: These are separate files so the includes are off.
import * as React from 'react';
import { Text, View, StyleSheet, SafeAreaView } from 'react-native';
import Constants from 'expo-constants';
// You can import from local files
import AssetExample from './components/AssetExample';
// or any pure javascript modules available in npm
import { NavigationContainer } from '#react-navigation/native'
import { createDrawerNavigator, DrawerContentScrollView, DrawerItem } from '#react-navigation/drawer'
import { createStackNavigator } from '#react-navigation/stack'
import { AppearanceProvider } from 'react-native-appearance'
const Drawer = createDrawerNavigator()
const Stack = createStackNavigator()
const HomeScreen = ({ navigation, route }) => {
return(
<View style={styles.container}>
<Text>Home Screen </Text>
</View>
)
}
const CategoryScreen = ({ navigation, route }) => {
return(
<View>
<Text>Category Screen </Text>
<Text>{JSON.stringify(route)}</Text>
</View>
)
}
const ProductScreen = ({ navigation, route }) => {
return(
<View>
<Text>Product Screen </Text>
<Text>{JSON.stringify(route)}</Text>
</View>
)
}
const CustomDrawerContent = ({ props }) => {
return (
<DrawerContentScrollView {...props}>
<DrawerItem
label="Home"
onPress={() => props.navigation.navigate('Home')}
/>
<DrawerItem
label="Category 1"
onPress={() =>
props.navigation.navigate('Main', {
Screen: 'Category',
params: { id: 1 },
})
}
/>
<DrawerItem
label="Category 2"
onPress={() =>
props.navigation.navigate('Main', {
Screen: 'Category',
params: { id: 101 },
})
}
/>
</DrawerContentScrollView>
)
}
const MainNavigator = () => {
return (
<Stack.Navigator>
<Stack.Screen name="Category" component={CategoryScreen} />
<Stack.Screen name="Product" component={ProductScreen} />
</Stack.Navigator>
)
}
const ApplicationNavigator = () => {
return (
<NavigationContainer initialRouteName="Home">
<Drawer.Navigator
drawerContent={(props) => {
return <CustomDrawerContent props={props} />
}}
>
<Drawer.Screen
name="Home"
component={HomeScreen}
/>
<Drawer.Screen
name="Main"
component={MainNavigator}
/>
</Drawer.Navigator>
</NavigationContainer>
)
}
export default function App() {
return <ApplicationNavigator />
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
padding: 8,
backgroundColor: '#FFFFFF',
},
});
UPDATE
I have noted that if I initialize the params (blank, with values, whichever) outside of the custom drawer content first, the above code begins to work as expected.
Very simple and silly fix that a rubber duck could solve.
Screen !== screen. I was passing in an unknown param to navigate.

Bottom tab bar should not occur anywhere but only on the first initial screen that renders via Webview in React Native

I have a webview component in my project, where the flow being =>
The bottomTabBar opens the initial screen of the url that is given to Webview source prop, which should remain, when any link is clicked on the webview and it moves to another screen, the bottomtabbar should not come up.
Below is my WebviewScreen code :
import React, {Component} from 'react';
import {WebView} from 'react-native-webview';
import {View, SafeAreaView, ActivityIndicator} from 'react-native';
export default class ConsultationHomeScreen extends Component {
renderLoadingView = () => {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<ActivityIndicator size="large" />
</View>
);
};
render() {
const {url} = this.props.route.params;
return (
<SafeAreaView style={{flex: 1}}>
<WebView
source={{uri: url}}
renderLoading={this.renderLoadingView}
startInLoadingState={true}
ref={(ref) => {
this.webview = ref;
}}
onNavigationStateChange={(event) => {
if (event.url !== url) {
this.webview.stopLoading();
}
}}
/>
</SafeAreaView>
);
}
}
And Appnavigation.js
import * as React from 'react';
import {NavigationContainer} from '#react-navigation/native';
import {createStackNavigator} from '#react-navigation/stack';
import {createBottomTabNavigator} from '#react-navigation/bottom-tabs';
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
import LoginScreen from '../screens/authentication/LoginScreen';
import OtpScreen from '../screens/authentication/OtpScreen';
import AddChild from '../screens/Child/AddChild';
import AcceptInviteScreen from '../screens/AcceptInviteScreen';
import ConsultationHomeScreen from '../screens/ConsultationHomeScreen';
import HomeScreen from '../screens/HomeScreen/HomeScreen';
import PlansScreen from '../screens/PlansScreen';
const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
function BottomTabBar() {
return (
<Tab.Navigator
lazy={false}
tabBarOptions={{
labelStyle: {
color: '#FF1493',
fontSize: 15,
},
}}>
<Tab.Screen
name="Home"
component={HomeScreen}
options={{
tabBarIcon: () => {
<MaterialIcon name="home" color="#FF1493" size={20} />;
},
}}
/>
<Tab.Screen
name="Consult"
component={ConsultationHomeScreen}
initialParams={{
url: 'some link',
}}
/>
<Tab.Screen name="Plans" component={PlansScreen} />
</Tab.Navigator>
);
}
export default function AppNavigation() {
return (
<NavigationContainer>
<Stack.Navigator headerMode="none">
<Stack.Screen name="login" component={LoginScreen} />
<Stack.Screen name="otp" component={OtpScreen} />
<Stack.Screen name="addchild" component={AddChild} />
<Stack.Screen
name="acceptinvitescreen"
component={AcceptInviteScreen}
/>
<Stack.Screen name="home" component={BottomTabBar} />
</Stack.Navigator>
</NavigationContainer>
);
}
However, am unable to remove the bottomtabbar,could anyone please suggest how should I implement this behaviour?
Step1-> Webview initial screen renders and has bottomtabtabr
Step2-> Link clicked on the initial screen and navigates to next screen handled by web source
Step3->Bottom tab bar should not occur anywhere but only on the first initial screen
Please,any suggestion would be appreciated and let me know if anything else is required for better understanding.
I tested this modification in your source code and it works like a charm.
GIT difference in WebviewScreen.js :
## -23,6 +23,7 ## export default class ConsultationHomeScreen extends Component {
}}
onNavigationStateChange={(event) => {
if (event.url !== url) {
+ this.props.navigation.setOptions({ tabBarVisible: false });
this.webview.stopLoading();
}
}}
Let me know if you have any issue.