Skip to content Skip to sidebar Skip to footer

How To Export CreateStackNavigator As Class In React Native?

I read here that using the the createStackNavigator as a Component class was possible, and I was trying to achieve that, but I always got an error. Instead of this: export default

Solution 1:

according to my understanding from the error I think the issue is not with your createStackNavigator the actual problem is that now from version 3 of react-navigation you have to manually pass the createStackNavigator into the createAppContainer so that the created Container can be the main component for React native to render

import { createAppContainer, createStackNavigator } from 'react-navigation';
// you can also import from @react-navigation/native

const AppNavigator = createStackNavigator(...);

// you have to pass the app navigator into app container like this
const AppContainer = createAppContainer(AppNavigator);

// Now AppContainer is the main component for React to render

export default AppContainer;

Post a Comment for "How To Export CreateStackNavigator As Class In React Native?"