假设我有以下代码片段来创建一个DrawerNavigator
export const DrawerApp = DrawerNavigator({
PageHome: {
screen: InboxScreen
},
},
{
contentComponent: props => <RightMenuScreen />,
drawerPosition: 'right'
});
我从这里的示例中读到,我可以banner
使用类似的语法将道具(如道具)传递给功能组件
const MyNavScreen = ({ navigation, banner }) => (<View><Text>{banner}</Text></View>);
// ...
// ...
// ...
const InboxScreen = ({ navigation }) => (
<MyNavScreen banner={'InboxScreen'} navigation={navigation} />
);
但是,如果我使用类 Component 声明我的 Component,我该如何归档将我的自定义 prop 传递给MyNavScreen
class InboxScreen extends Component {
render() {
// here I want to get a prop like `banner` or `callback` from props
}
}