Judy M.
Judy M.

Reputation: 243

Setting modal mode to specific screen

I'm using stack navigator in my react-native app, i have set the mode to modal so the screen gets pushed from the bottom, it's working fine but is there a way to specify this mode for specific screens only?

const App = createStackNavigator({
  Home: { screen: Home },
},
{
  mode: 'modal',
 }
);

Upvotes: 2

Views: 907

Answers (1)

Jeff Gu Kang
Jeff Gu Kang

Reputation: 4879

Solution

Use multiple StackNavigator.

For example, if you want show Modal screen using modal effect only

// Call `this.props.naviation.navigate('Modal') from `Basic` screen, and use 'goBack()' in `Modal` screen.
const ModalStack = createStackNavigator({
  Basic: { screen: Basic },
  Modal: {screen: ModalScreen },
},
{
  mode: 'modal',
 }
);

const Modal = createStackNavigator({
  Home: { screen: Home },
  Detail: { screen: ModalStack },
},
);

Upvotes: 2

Related Questions