diff --git a/README.md b/README.md index 8f39a4796..523b555a0 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ npm i react-native-router-flux --save | schema | string | optional | Set this property to the name of a previously defined `Schema` to inherit its properties | | wrapRouter | bool | false | If `true`, the route is automatically nested in its own `Router`. Useful for modal screens. For type==switch wrapRouter will be true| | sceneConfig | Navigator.SceneConfigs | optional | Defines the transition animation. | +| defaultRoute | string | optional | Defines which route to go to if this route is used as a tab and the tab is clicked on when the tab is already selected | ##### Schema: diff --git a/TabBar.js b/TabBar.js index a0893bef3..8e020f095 100644 --- a/TabBar.js +++ b/TabBar.js @@ -11,7 +11,11 @@ export default class TabBar extends React.Component { if (!Actions[el.props.name]){ throw new Error("No action is defined for name="+el.props.name+" actions:"+JSON.stringify(Object.keys(Actions))); } - Actions[el.props.name](); + if (el.props.selected && Actions[el.props.defaultRoute]) { + Actions[el.props.defaultRoute](); + } else { + Actions[el.props.name](); + } InteractionManager.runAfterInteractions(() => this.setState({hideTabBar: el.props.hideTabBar})); return {selected: true};