Skip to content
This repository has been archived by the owner on Nov 30, 2018. It is now read-only.

WIP: Add replace action to navigation and make navigation type more generic #125

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

fakenickels
Copy link
Contributor

@fakenickels fakenickels commented Sep 23, 2018

Making navigation type more generic

navigation is now derived from the parametric type commonNavigation('a) so we can sure for instance the same header component across different StackNavigators.

let make = (~navigation: Rebolt.StackNavigator.commonNavigation('a), _children) => {
 ...component,
 render: _self => {
  <View>
   <BackButton onPress={(_) => navigation.pop()}>
 </View>
 }
}

navigation.replace(Config.route)

I moved around a couple of things to accommodate the replace action.
Mainly they were

  • Move the transition side effect logic from didUpdate to inside the reducer so the side effect is more explicit/direct
  • Use Belt.Array to remove a screen by in RemoveStaleScreen (ReArray.remove, because of spliceInPlace, does not work with 0 indexes).

Missing

Add to the documentation

Let me know if I can improve anything else before merging

@@ -322,6 +331,10 @@ module CreateTabNavigator = (Config: {type route;}) => {
screens[index] = {...screens[index], tabItem};
ReasonReact.Update({...state, screens});
},
didMount: self => {
onNavigationReady(getNavigationInterface(~send=self.send, ~screens=self.state.screens, ~currentRoute=self.state.currentRoute, ~isActive=true, ~index=0));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed for deeplinking
we are using this so we can lift to a parent the state handling and navigation actions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants