【发布时间】:2017-03-28 05:06:37
【问题描述】:
我正在学习 react-native 导航 https://reactnavigation.org/docs/intro/ 。我在示例中看到了
class HomeScreen extends React.Component {
static navigationOptions = {
title: 'Welcome',
};
render() {
const { navigate } = this.props.navigation;
return (
<View>
<Text>Hello, Chat App!</Text>
<Button
onPress={() => navigate('Chat')}
title="Chat with Lucy"
/>
</View>
);
}
}
我无法理解const { navigate } = this.props.navigation; 的这行代码到底是什么
【问题讨论】:
-
这叫做解构赋值。和
const navigate = this.props.navigation.navigate一样。 -
@AndrewLi 非常感谢!
标签: react-native react-navigation