Javascript React native无法识别静态变量
我尝试使用navigationOptions,但reactNative不识别“静态” 我试过使用类,但效果很好,但使用函数却不起作用Javascript React native无法识别静态变量,javascript,react-native,Javascript,React Native,我尝试使用navigationOptions,但reactNative不识别“静态” 我试过使用类,但效果很好,但使用函数却不起作用 export default function Home() { static navigationOptions = { title: 'Home', }; return ( <View style={styles.container}> <Text style={styles.h1}>Home&l
export default function Home() {
static navigationOptions = {
title: 'Home',
};
return (
<View style={styles.container}>
<Text style={styles.h1}>Home</Text>
</View>
);
}
Uncaught (in promise) TypeError: Cannot read property 'concat' of undefined
at DeltaPatcher.applyDelta (DeltaPatcher.js:77)
at deltaUrlToBlobUrl (deltaUrlToBlobUrl.js:28)
at async getBlobUrl ((index):237)
at async WebSocket.ws.onmessage ((index):192)
导出默认函数Home(){
静态导航选项={
标题:"家",,
};
返回(
家
);
}
未捕获(承诺中)TypeError:无法读取未定义的属性“concat”
在DeltaPatcher.applyDelta(DeltaPatcher.js:77)
在Deltaurltobul(deltaurltobul.js:28)
异步getBlobUrl((索引):237)
异步WebSocket.ws.onmessage((索引):192)
在您的示例中,您可以创建一个由所有实例共享的静态变量,如下所示:
export default function Home() {
return (
<View style={styles.container}>
<Text style={styles.h1}>Home</Text>
</View>
);
}
Home.navigationOptions = {
title: 'Home',
};
导出默认函数Home(){
返回(
家
);
}
Home.navigationOptions={
标题:"家",,
};
在JavaScript中,函数是一级对象。因此,作为一个对象,您可以为函数指定属性
在ES6中,class关键字引入了一个伴随的静态关键字。
Home
是一个函数,而不是类。