I want to add an action to the tab,and such like this :
<Scene key="main" tabs={true} ...>
<Scene key="AAAA" component={AAAPage} .../>
<Scene key="Button" onPress={()=> ... } .../>
<Scene key="CCCC" component={CCCPage} .../>
</Scene>
the scence 'button' can add onPress protype to bind an action.
IMO this is out of scope of this project. This is a navigation stack.
Also adding this new feature can significantly disrupt onPress calls from downstream components or can introduce delays in complex views; for example views using ListView
You can accomplish this by simply adding onPress in the top view of each of your pages.
fix react-native-router-flux/src/TabBar.js onSelect function.
...
export default class extends Component {
onSelect(el){
const state = this.props.navigationState;
if (!Actions[el.props.name]){
throw new Error("No action is defined for name="+el.props.name+" actions:"+JSON.stringify(Object.keys(Actions)));
}
// rewrite Actions[el.props.name]();
if (!el.props.modal) {
Actions[el.props.name]();
}
else {
el.props.onPress();
}
}
...
react native files look like this:
<Scene key="main" tabs={true}>
...
<Scene key="OtherPage" component={OtherPageModal} modal={true} onPress={()=>alert("Test")} ... />
...
</Scene>
perfect!!!
Most helpful comment
fix react-native-router-flux/src/TabBar.js onSelect function.
react native files look like this: