Tell us which versions you are using:
I want to do something after onRight event in scene's component. I think it is not suitable to do component logic in root scene. use action? can i override onRight in subcomponent?
Yes this can be overrided at scene level.
var tabSceneMenu = {
onLeft :()=>{ MenuActions.openMenu() },
leftButtonImage:leftImage,
getLeftTitle:this.getLeftTitle,
getRightTitle:this.getRightTitle,
onRight :()=>{MenuActions.openRightMenu();}
}
<Scene key="newTab" {...tabSceneMenu} passProps={true} component={YourComponent} title="Title" ></Scene>
How can you use MenuActions inside YourComponent?
try this:
<Scene
component={CustomerCheckListView}
title="test" rightTitle="confirm" onRight={(scene, proxy) => {
scene.component.WrappedComponent.prototype.confirm();
}}
/>
and have confirm method in your component.
scene.component.WrappedComponent.prototype.confirm() - worked, but the props of the component are not visible in the called component method, any suggestions!!
many developers call Actions.refresh() method in componentWillMount to override onRight/onLeft/onCancel method.
Actions.refresh({rightTitle: "foo", onRight: this._save});
u can refer to this issue: https://github.com/aksonov/react-native-router-flux/issues/634
Given current Renderer of Scene is stateless, I think this is the only way to get component context in onRight/onLeft method.
someone said this workaround might have side effects like double render?? I haven't tested it since everything works fine and performance is not affected at all...
Thanks zichong.
Calling Actions.refresh({rightTitle: "foo", onRight: this._save}) method in componentWillMount works but if in your app will you call Actions.NAME_SCENE this will cause calling scene componentWillMount over and over
Most helpful comment
try this:
and have
confirmmethod in your component.