私は学校のためのプロジェクトに取り組んでいます。確かに私はJavaScriptに関して初心者です。私はReact Navigation tutorialでconst型を使用する理由を理解していません。React Nativeでなぜconst型が使用されているのですか?const {navigate} = this.props.navigation ;?
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型が使用されているconst { navigate } = this.props.navigation;
どうしてですか? 'navigate'関数は決して変更されません。これは単純な略語なので、完全な識別子ではなく 'navigate( 'Chat')'と書くことができます。 – cmbuckley