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

Conversation

WoLewicki
Copy link
Member

@WoLewicki WoLewicki commented Aug 25, 2020

Following the implementation of Modal in react-native: https://github.com/facebook/react-native/blob/master/Libraries/Modal/Modal.js#L206, we attach each screen that is presented modally with an AppContainer that has a listener for LogBox and ElementInspector. This allows for these elements to pop up over the modal screen. There will be 2 ElementInspectors on the first screen due to 2 AppContainer components rendered in it. If we added check for if the index === 0, changing that index would unmount and remount screen content while calling e.g. navigation.reset(). Should resolve #268.

Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

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

Please respond to my inline comment. Accepting to unblock otherwise.

@@ -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;
}

@WoLewicki WoLewicki merged commit 620d063 into master Sep 8, 2020
@WoLewicki WoLewicki deleted the @wolewicki/add-app-container branch September 8, 2020 14:38
@brentvatne
Copy link
Collaborator

it might be worth opening a pr against react-native to expose this as a public api, what do you think @kmagiera?

@kmagiera
Copy link
Member

yes, I think it makes sense, react-native's modal uses that and I think there are some plans to move it out of the core repo. It'd be necessary to expose a way for modal to work outside of the core anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't use rn element inspector on modal
3 participants