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

Made old StateContext values Idempotent #257

Merged
merged 25 commits into from
Jul 1, 2019
Merged

Conversation

grahammendick
Copy link
Owner

There was a bug with shared elements on Navigation React Mobile. In the 'zoom' example, double tapping the x button stopped the shared element animation. On the first tap the oldState is 'color' State, but on the second tap the oldState becomes 'colors'. When the oldState changes the shared element animation stops. The navigation wasn't fully idempotent because the old StateContext values changed on multiple taps.

Changed to make the navigation fully idempotent. Multiple navigation taps always results in an identical StateContext.

On Mobile and Native, the navigation was only idempotent for the next and previous state and data but not for the old state and data. It was ok to double tapping because it wouldn't change the crumb trail. But double tapping would change the old state. For example, a double tap a link that navigates A --> B. The first tap the old State is A. The second tap the old State is B because it took the old State from the top level context.
Instead, taken the context from the async state navigator not the top level state navigator. That way the old State is always A because the async state navigator stays  the same for scene A
Built link from 'old' state navigator and passed it to current one passing in the old context
Built link from 'old' state navigator and passed it to current one passing in the old context
Built link from 'old' state navigator and passed it to current one passing in the old context
Built link from 'old' state navigator and passed it to current one passing in the old context
It's possible the url could be match but the context might've changed, e.g., naivgate A --> B then do a paused navigation to C and before it returns navigate to D and back to B. When C returns it's still at B but it shouldn't resume because it was superceded by D.
The context is now updated immutably so context only changed if navigation has happened.
@grahammendick grahammendick merged commit 63392a4 into master Jul 1, 2019
@grahammendick grahammendick deleted the full-idempotent branch July 1, 2019 08:14
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.

1 participant