Closed
Conversation
Contributor
|
Several issues with dependency arrays using ref.current were found, which can lead to unreliable effects since ref updates do not trigger re-renders. |
Contributor
|
Closing in favor of #54 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a breaking change. We probably should make a version 0.4 if we want to do it like this.
The issue is, that on disconnect when we have a logic like
where we actually want to hide the trip selector based on other props, the mapTemplate would actually not be valid anymore in the cleanup function on unmount. However it is still defined, so calling that action we will run the native code, although it is already in the process of tearing down everything. Right now this would cause an exception, that the scene is not valid anymore.
When using a ref like in this PR we would be able, to immediately reset the state of the mapTemplate, even if the UI wouldn't render anymore. So the useEffect would look like this:
And the cleanup function wouldn't do anything, as the ref is already set to null when getting there.
This could potentially replace #52 as we wouldn't have to check for the connection state on native side. We could however still keep the logic about not throwing when the scene is gone. Not sure though if we actually need it...