小编Chr*_*yes的帖子

在 React Native 中为什么使用 const 类型,例如:const { navigate } = this.props.navigation;?

我正在为学校做一个项目并使用 react native。诚然,我是 JavaScript 的新手。我不明白为什么在React Navigation 教程中他们使用 const 类型。

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>
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

所以我的问题是: const 类型用于 const { navigate } = this.props.navigation;

javascript types react-native stack-navigator

5
推荐指数
1
解决办法
9532
查看次数

标签 统计

javascript ×1

react-native ×1

stack-navigator ×1

types ×1