Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 对类组件使用导航传递道具_React Native_React Native Navigation - Fatal编程技术网

React native 对类组件使用导航传递道具

React native 对类组件使用导航传递道具,react-native,react-native-navigation,React Native,React Native Navigation,假设我有以下代码片段来创建一个DrawerNavigator export const DrawerApp = DrawerNavigator({ PageHome: { screen: InboxScreen }, }, { contentComponent: props => <RightMenuScreen />, drawerPosition: 'right' }); 但是,如果我使用类组件声明我的组件,我如何归档将自定

假设我有以下代码片段来创建一个
DrawerNavigator

export const DrawerApp = DrawerNavigator({
    PageHome: {
        screen: InboxScreen
    },
},
{
    contentComponent: props => <RightMenuScreen />,
    drawerPosition: 'right'
});
但是,如果我使用类组件声明我的组件,我如何归档将自定义道具传递到
MyNavScreen

class InboxScreen extends Component {

    render() {
        // here I want to get a prop like `banner` or `callback` from props
    }
}

通过使用this.props可以实现同样的效果

class InboxScreen  extends Component{
static navigationOptions = {
  drawerLabel: 'Inbox',
  drawerIcon: ({ tintColor }) => (
    <MaterialIcons
      name="move-to-inbox"
      size={24}
      style={{ color: tintColor }}
    />
  ),
};
render (){
  return(
  <MyNavScreen banner={'Inbox Screen'} navigation={this.props.navigation} />
  );
}
}
类InboxScreen扩展组件{
静态导航选项={
抽屉标签:“收件箱”,
抽屉图标:({tintColor})=>(
),
};
渲染(){
返回(
);
}
}
class InboxScreen  extends Component{
static navigationOptions = {
  drawerLabel: 'Inbox',
  drawerIcon: ({ tintColor }) => (
    <MaterialIcons
      name="move-to-inbox"
      size={24}
      style={{ color: tintColor }}
    />
  ),
};
render (){
  return(
  <MyNavScreen banner={'Inbox Screen'} navigation={this.props.navigation} />
  );
}
}