Javascript 如何使用react native中的Navigator替换主组件中的特定子组件

Javascript 如何使用react native中的Navigator替换主组件中的特定子组件,javascript,jquery,reactjs,react-native,Javascript,Jquery,Reactjs,React Native,在我的场景中,有如此多的子组件。但特定的子组件我需要用所有其他子组件填充新数据 var MainComponent = React.createClass({ renderScene:function(route, navigator) { var type=this.props.type; if(type =="text"){ <GetInputField/> } el

在我的场景中,
有如此多的子组件。但特定的子组件我需要用所有其他子组件填充新数据

var MainComponent =  React.createClass({ 
     renderScene:function(route, navigator) {

         var type=this.props.type;
         if(type =="text"){
            <GetInputField/>
          }
         else if(type=="number"){
            <GetNumberField/>
         }
         else if(type=="image"){
            <GetImageField />

     //using this <GetImageField> component i am showing two buttons.
     //while click on the button i moving to another scene .
     //in this scene i am showing local images using CameraRoll component.
    // When select the image i need to populate that image in the <GetImageField/> component  through the navigator.
    // But i am unable to replace to the <GetImageField/> component using navigator
         }

     },

      render:function() {
          return(<Navigator
               renderScene={this.renderScene.bind(this)}
               navigator={this.props.navigator}
               navigationBar={
                 <Navigator.NavigationBar style={styles.navBarStyle}
                     routeMapper={NavigationBarRouteMapperDisplayCustomSchema} />
               } />)
     }

 })
var MainComponent=React.createClass({
renderScene:函数(路线、导航器){
var type=this.props.type;
如果(类型=“文本”){
}
else if(类型=“编号”){
}
else if(类型==“图像”){
//使用这个组件,我显示了两个按钮。
//单击按钮时,我移动到另一个场景。
//在这个场景中,我使用CameraRoll组件显示本地图像。
//选择图像时,我需要通过导航器在组件中填充该图像。
//但我无法使用navigator替换为组件
}
},
render:function(){
返回()
}
})

在我的场景中,我需要用

的其他组件填充
组件中的图像,如果
CameraRoll
GetImageField
的子组件,您只需传递回调属性即可。例如:

var GetImageField = React.createClass({
  render: function() {
    return <CameraContainer onPhotoSelected={this.updatePhotos} />
  },

  updatePhotos: function(images) {
    this.setState({ images });
  }
});
var GetImageField=React.createClass({
render:function(){
返回
},
updatePhotos:函数(图像){
this.setState({images});
}
});
如果它不是子对象,那么您可能需要使用事件来传播信息

也许值得一读