我的RNNv2顶部栏中有一个自定义组件“ MenuButton”。我希望单击该按钮时运行openMenu(),但这不会发生。我的打字稿掉毛告诉我Property openMenu does not exist on typeof Home
。为什么是这样?
class Home extends React.PureComponent{ constructor(props: Props) { super(props); Navigation.events().bindComponent(this); } closeMenu = () => { this._drawer.close(); }; openMenu = () => { this._drawer.open(); }; static options(passProps) { return { topBar: { rightButtons: [ { component: { name: 'MenuButton', passProps: { onClick: () => this.openMenu(), }, }, }, ], }, }; } render() { return ( ... ); } }
参考我passProps
从以下网址获得了代码:https : //github.com/wix/react-native-navigation/issues/3648