-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Reload (from dev menu) should call onHostDestroy or any other event to detect Reload #9773
Comments
@facebook-github-bot label Icebox |
Hi there! This issue is being closed because it has been inactive for a while. But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/reload-from-dev-menu-should-call-onhostdestroy-or-any-other-event-to-detect-reload ProductPains helps the community prioritize the most important issues thanks to its voting feature. Also, if this issue is a bug, please consider sending a PR with a fix. |
@facebook-github-bot close |
@charpeni tells me to close this issue. If you think it should still be opened let us know why. |
This is unfortunate. Some sort of event should be called to clean up resources. |
IMO unfortunate is also approach how reported issues are just closed without any comment. I appreciate any guy who is working hard on react-native, but for me as reporter and plugin developer who is making plugins in his free time (unpaid) this approach is very frustrating. |
This comment has been minimized.
This comment has been minimized.
@mauron85: how did you end up solving this? |
@lucasbento I don't think I actually solved satisfactorily. I just fixed the crash but lot problems remained. |
@lucasbento. I don't see any reopen button here. So I can not. |
@lucasbento Sure, let's reopen it. |
how is this still not fixed? it surely can't be difficult to provide SOME kind of event when the app has been reloaded from the dev menu |
I suppose it may be difficult to send an event to the JS side, because it would require the native side to wait synchronously for the JS call stack to complete, something React Native is not (yet) designed for. Perhaps this functionality will be available after React Native's is redesigned internally. |
I was not talking about js side, rather native java. Add event onBeforeDestroy (or similarly named) to LifecycleEventListener.java interface and of course call that method on the caller side (whatever that java class is). |
I'm aware. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
I am reopening this. It's still an issue and we need a way to clean up resources when we reload the app. It's been really hard for me to clean up resources. If there's anyone knowing a better workaround, please let me know. CC: @kmagiera maybe you happen to have a better context here? |
So basically I think the behavior is correct ( |
IIRC, there is no default way to notify native module if JS reloaded. But you can have native method and call it on componentDidMount() a component to do the binding. |
Thank you guys for amazing work
Issue Description
I'm developing react-native-background-geolocation. While working on this issue, I've identified potential problem within my module logic and Reload (from dev menu) functionality.
In my module I'm creating LocationService similar to android MessengerService from android examples.
In BackgroundGeolocationModule I'm binding to this service (and starting it) on user request (from js). Module should unbind from service on onHostDestroy (LifecycleEventListener) method (this part is not in my repo yet).
However it seems Reload doesn't call onHostDestroy or any other event to detect Reload event. As result client (module) client will be binding to service twice, which leads to java.lang.IllegalStateException: "This message is already in use" and app crash.
Steps to Reproduce / Code Snippets
Expected Results
Event that is sent before react-native will do Reload, so we can unbind from service.
Additional Information
Addtional description also here:
http://stackoverflow.com/questions/39354236/android-how-to-prevent-binding-to-remote-messenger-service-twice-to-prevent-java?noredirect=1#comment66039454_39354236
The text was updated successfully, but these errors were encountered: