mad*_*ddy 5 navigation react-native react-navigation
我坚持在里面添加保存方法navigationOptions
,请你帮我做正确的方法.
static navigationOptions = ({navigation}) => ({
headerTitle: "Add New Item",
...css.header,
headerRight: <NavViewRight
onPress={() => this.rightHeaderAction()} />,
})
Run Code Online (Sandbox Code Playgroud)
实际上还不清楚你到底想要做什么.但似乎你想从静态方法中调用类中的非静态方法.
你指的是this
,但this
这里并不意味着类实例.为了从你的类中调用某些东西,你需要将方法设为静态.
像这样的东西:
class MyScreen extends Component {
static navigationOptions = ({
navigation
}) => ({
headerTitle: "Add New Item",
...css.header,
headerRight: < NavViewRight
onPress = {
() => MyScreen.rightHeaderAction()
}
/>,
})
static rightHeaderAction() {
// your code here
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1881 次 |
最近记录: |