IjzerenHein / react-navigation-shared-element

React Navigation bindings for react-native-shared-element 💫
https://github.com/IjzerenHein/react-native-shared-element
MIT License
1.27k stars 124 forks source link

Correctly navigate to/from screens of the same name. #221

Closed iamdavidmartin closed 1 year ago

iamdavidmartin commented 2 years ago

In createSharedElementScene.tsx, changed function to use route.key instead of route.name when checking to see if the current route is active. Previously, all screens that had the same name in the stack think that they are active when the navigation event fires. This correctly finds the one screen that is active to perform the correct transition.

In SharedElementRendererData, when updating share elements, use variable to correctly send the screen's 'sharedElements' function the showing state. This fixes a bug where, if a user went backwards to a screen of the same name, the "showing" parameter in the 'sharedElements' function would be true when it should be false.

Please take a look at the example I added. These fixes now allow for properly navigating back and forthwith a screen of the same name.

Here's the issue I created that this PR addresses.

https://github.com/IjzerenHein/react-navigation-shared-element/issues/220

haibert commented 2 years ago

@IjzerenHein this seems interesting 👀I think it deserves a review Hein!