However, this package itself specifies a `main` module field that could not be resolved

After a long research MetroJS bundler default not compile typescript .ts and .tsx extension files. We need tell MetroJS bundler to compile .ts and .tsx files i solved this error by edit metro.config.js file in root project folder by following. Edited on September 2022 Added cjx and json extensions to below snippet All extensions listed … Read more

Disable back button in react navigation

1) To make the back button disappear in react-navigation v5 or newer: { navigationOptions: { title: ‘MyScreen’, headerLeft: ()=> null, // `headerLeft: undefined` should work too // `headerLeft: null` should work but could trigger a TS error } NOTE: v6 has an extra option: headerBackVisible: false​ Whether the back button is visible in the header. … Read more

React Navigation how to hide tabbar from inside stack navigation

To hide the tab bar in one of the screens, this works for React Navigation v4: HomeStack.navigationOptions = ({ navigation }) => { let tabBarVisible = true; let routeName = navigation.state.routes[navigation.state.index].routeName if ( routeName == ‘ProductDetails’ ) { tabBarVisible = false } return { tabBarVisible, } } For v5, and v6 please check @Chathuranga Kasthuriarachchi’s … Read more

Invariant Violation: requireNativeComponent: “RNSScreen” was not found in the UIManager

Faced the same issue while implementing Navigation. Run following commands npm install @react-navigation/native React Navigation is made up of some core utilities and those are then used by navigators to create the navigation structure in your app.
 In your project directory, run: npm install react-native-reanimated react-native-gesture-handler react-native-screens react-native-safe-area-context @react-native-community/masked-view This will install versions of these … Read more

Pass props from child to parent react navigation

There is really simple solution to pass back props to parent component on goBack(). You can pass an extra prop containing function to Modal and right before calling goBack() or in componentWillUnmount you can call that function. Example export default class SomeComp extends Component { … onGoBack = (someDataFromModal) => { console.log(someDataFromModal); } render() { … Read more

StackNavigator through Component gives undefined error

Since your Test component does not belong to navigation stack it doesn’t have the navigation prop. You can do couple of things. Simple one is to pass the navigation to the child component like the example below. return ( <View> <Text>Hello, Chat App!</Text> <Button onPress={() => navigate(‘Chat’, { user: userName })} title={“Chat with ” + … Read more

How to navigate between different nested stacks in react navigation

In React Navigation 5, this becomes much easier by passing in the screen as the second parameter: navigation.navigate(‘Nested Navigator 2’, { screen: ‘screen D’ }); You can also include additional levels if you have deeply nested screens: navigation.navigate(‘Nested Navigator 2’, { screen: ‘Nested Navigator 3’, params: { screen: ‘screen E’ } });

How to reset TabNavigator when user logs out (from other screen)

This should work in most cases: componentWillReceiveProps(nextProps) { if ( nextProps.token == undefined || _.isNil(nextProps.token) ) { let action = NavigationActions.reset({ index: 0, key: null, actions: [ NavigationActions.navigate({routeName: ‘Auth’}) ] }); nextProps.navigation.dispatch(action); } … } Or try by enhancing your navigator with custom action: const changeAppNavigator = Navigator => { const router = Navigator.router; const … Read more