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

[V2] Lack of componentWillAppear/componentWillDisappear #4793

Closed
aafarian opened this issue Feb 26, 2019 · 4 comments
Closed

[V2] Lack of componentWillAppear/componentWillDisappear #4793

aafarian opened this issue Feb 26, 2019 · 4 comments

Comments

@aafarian
Copy link

Issue Description

We don't have access to a componentWillAppear/componentWillDisappear in V2.

Currently, when trying to migrate onNavigatorEvent events, we can migrate "didAppear", "didDisappear", "bottomTabReselected" (although for that one we have to manually compare the current/target tab to see if they're the same).

"didAppear" --> componentDidAppear
"didDisappear" --> componentDidDisappear
"willAppear" --> ?
"willDisappear" --> ?

I'm aware that we have componentDidMount/componentDidUnmount, but those will not fire when a modal is opened/closed that was on top of your screen, whereas "didAppear" used to fire on a root page when you closed a modal on top of it and "didDisappear" will fire off when you open a modal on top of a root page.


Environment

  • React Native Navigation version: 2.12.0
  • React Native version: 0.55.4
  • Platform(s) (iOS, Android, or both?): iOS
  • Device info (Simulator/Device? OS version? Debug/Release?): Simulator
@donovanhiland
Copy link

Have you by chance subscribed to navigation events in this component via something like:

  componentDidMount() {
    this.navigationEventListener = Navigation.events().bindComponent(this);
  }

@aafarian
Copy link
Author

@donovanhiland yes, I've subscribed - which gives me access to componentDidAppear and componentDidDisappear, but not componentWillAppear (or an equivalent) or componentWillDisappear (or an equivalent). In fact, if you search through the whole repo, you won't find those anywhere.

@guyca
Copy link
Collaborator

guyca commented Feb 27, 2019

Hey @aafarian
Indeed, v2 doesn't expose "will events" simply because they aren't reliable. In v1, both willAppear and willDisappear were emitted from native. This makes them irrelevant since if the bridge or Js thread are busy, they will be handled by you after the component has already appeared. In other words, they are meaningless due to the async nature of RN.

@erennyuksell
Copy link

@guyca please expose componentWillDisappear event

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

No branches or pull requests

4 participants