对于2个简单组件,父级,子级都使用Redux I能够使用refs
来调用子方法。但是我怎样才能使用上面的库' react-native-router-flux',在哪里可以将ref设置为场景。
为父级
var Parent = new React.createClass({
render : function() {
return (<Child ref={(child) => {this.child = child}})
}
// able to trigger child.somefunction via this.child.getWrappedInstance().somefunction()
})
module.exports = connect(select)(Parent)
ChildComponent
var Child = new React.createClass({
somefunction: function(){
//working
}
})
module.exports = connect(select, null, null, {withRef: true})(Child)
https://github.com/aksonov/react-native-router-flux
使用上面的库后,使用子组件的渲染功能
render: function() {
return (
<Router>
<Scene>
<Scene key="WelcomeModal" component={WelcomeModal} title="welcomeTitle" initial={true}
navigationBarStyle={styles.welcomeModal_navigationBarStyle}
titleStyle={styles.welcomeModal_titleStyle}
rightTitle='INFO'
rightButtonStyle={styles.baseModal_rightButtonStyle}
rightButtonTextStyle={styles.baseModal_rightButtonTextStyle}
rightButtonIconStyle={styles.baseModal_rightButtonIconStyle}
ref={(_WelcomeModal) => {this._WelcomeModal = _WelcomeModal}} //need some way to add ref here
/>
</Scene>
</Router>
)
}