nearform / open-banking-reference-app

NearForm reference application for open banking - https://community.nearform.com/api-banking
Other
28 stars 16 forks source link

Proposed changes to native routing and navigation #17

Open AlanSl opened 4 years ago

AlanSl commented 4 years ago

The changes proposed here are to be implemented and tested in the Polaris Shopping demo app first, then, if they work as expected there, backported here.

The current approach to routing has been the same since the first commit to https://github.com/nearform/open-banking-reference-app-original-private in May 2019:

My proposal is to use an approach similar to what is described here - https://www.ythecombinator.space/posts/driving-towards-a-universal-navigation-strategy-in-react - based on a case very similar to ours, written on 2020.

Essentially the approach is:

Benefits of this approach:

AlanSl commented 4 years ago

Another possibility is React Native Navigation, which is also endorsed by the official React Native docs. The main benefit of React Native Navigation is that it uses purely-native navigation with a thin JavaScript layer, whereas React Navigation does more in Javascript and React components.

As I see it that is probably more of a drawback than a benefit for us:

However with the approach of forking platforms in a hook, it should be possible that if a rare project did have very niche navigation needs, it should be possible to swap RNN in only changing the logic in the .native.ts custom hook (after getting RNN working with the main infrastructure, which appears to be non-trivial).

AlanSl commented 4 years ago

Most other React Native navigation libraries appear to be simply opinionated layers on top of React Navigation.

React Router Native is different and interesting but appears to not help us get native transitions, which is the main thing we want.

React Native Screens looks like it might be worth using alongside React Navigation. It brings in more native components than React Navigation and appears to integrate well with the rest of our stack. I'll try it and see if it improves things. It's already integrated into React Navigation 5.X

React Navigation is bringing in web support, but it doesn't look ready for production yet. After just 5 minutes playing around with https://react-navigation-example.netlify.app/ I had got it in a state where the browser back button had stopped working.