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

[Android] registerComponentDidAppearListener not triggering (sometimes) on functional components (release mode) #5244

Closed
jpgarcia opened this issue Jun 30, 2019 · 8 comments

Comments

@jpgarcia
Copy link
Contributor

jpgarcia commented Jun 30, 2019

Issue Description

If you use a functional (with hooks) component for a screen and you use registerComponentDidAppearListener you could end up with the events not being triggered (only on Android and in release mode)

Steps to Reproduce / Code Snippets / Screenshots

I have created a simple react-native project on a public repo to reproduce it. The example reproduce the DidAppear not working on Android release mode only

The project includes a screen implemented as a Functional Component (with hooks) and also a PureComponent with the same behavior.

On Android (Debug Mode)

react-native run-android
The sample works perfect on both Functional and PureComponent

On Android (Release Mode)

react-native run-android --variant=release
The sample works perfect on the PureComponent implementation but the Functional doesn't work

ezgif-2-c6b40be6fbf1
Video of the example app running in release mode


Environment

  • React Native Navigation version: 2.22.1
  • React Native version: 0.59.9
  • Platform(s) (iOS, Android, or both?): Android
  • Device info (Simulator/Device? OS version? Debug/Release?): Simulator and Device (Only Release Mode)
@jpgarcia jpgarcia changed the title [Android] registerComponentDidAppearListener not triggering (sometimes) on stateless components (release mode) [Android] registerComponentDidAppearListener not triggering (sometimes) on functional components (release mode) Jun 30, 2019
@rendomnet
Copy link

@guyca Any updates on this issue?

@samithaf
Copy link

Also seems like life cycle hook is pretty slow on Android and I am testing the App on Samsung S10 so can't be the device is slow. Furthermore on iOS seems everything smooth.

@stale
Copy link

stale bot commented Sep 12, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

@stale stale bot added the 🏚 stale label Sep 12, 2019
@jpgarcia
Copy link
Contributor Author

The issue is still happening it would be awesome if someone can take a look into.

There's a I have simple react-native project to reproduce de issue here -> https://github.com/jpgarcia/rnn-events-issue

@stale stale bot removed the 🏚 stale label Sep 12, 2019
@samithaf
Copy link

Looks like life cycle hook is not guarantee to get fire on Debug build too. It's still happening:(

@stale
Copy link

stale bot commented Oct 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

@stale stale bot added the 🏚 stale label Oct 14, 2019
@cfranchella
Copy link

Hey @guyca do you have any updates on this issue? Thanks!

@stale stale bot removed the 🏚 stale label Oct 17, 2019
@jpgarcia
Copy link
Contributor Author

@sintylapse mentioned here Nubescope/react-native-navigation-hooks#7 the cause of the events not being triggered.

Basically you must use useLayoutEffect instead of useEffect 🚀

BTW I just published a new version of react-native-navigation-hooks which includes this fix

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