Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add appContainer to modal screens #614

Merged
merged 4 commits into from
Sep 8, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/native-stack/views/NativeStackView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '@react-navigation/native';
import * as React from 'react';
import { Platform, StyleSheet, View } from 'react-native';
import AppContainer from 'react-native/Libraries/ReactNative/AppContainer';
import {
Screen as ScreenComponent,
ScreenProps,
Expand Down Expand Up @@ -35,7 +36,7 @@ export default function NativeStackView({

return (
<ScreenStack style={styles.container}>
{routes.map((route) => {
{routes.map((route, index) => {
const { options, render: renderScene } = descriptors[route.key];
const {
gestureEnabled,
Expand Down Expand Up @@ -106,7 +107,16 @@ export default function NativeStackView({
});
}}>
<HeaderConfig {...options} route={route} />
<View style={viewStyles}>{renderScene()}</View>
{__DEV__ &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEV checks can be stripped in build time but not when used like this. You can define a debug container in top level as follows and the use a simple if (DEV) statement:



let Container = View;

if (__DEV__) {
  const DebugContainer = (props) => <AppContainer><View {...props}/></AppContainer>
  Container = DebugContainer;
}

Platform.OS === 'ios' &&
stackPresentation !== 'push' &&
index !== 0 ? (
<AppContainer>
<View style={viewStyles}>{renderScene()}</View>
</AppContainer>
) : (
<View style={viewStyles}>{renderScene()}</View>
)}
</Screen>
);
})}
Expand Down