我目前正在尝试为我的React本机应用程序理解App.js文件中的一些JavaScript代码。我想知道<AppLoading/> <View>
组件的代码是HTML代码还是JavaScript代码?
export class App extends React.Component {
state = {
isLoadingComplete: false,
};
render() {
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
return (
<AppLoading
startAsync={this._loadResourcesAsync}
onError={this._handleLoadingError}
onFinish={this._handleFinishLoading}
/>
);
} else {
return (
<View style={styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
<AppNavigator />
<View/>
);
}
}
答案 0 :(得分:2)
这是JavaScript的语法扩展,称为JSX。 You can read about it here。
您可以或多或少像常规HTML那样考虑它,但是有一些重要的语法差异(例如,将class
属性替换为className
,如果有多个同级则需要一个父元素,等等)。 )以及将JS表达式插入大括号中的功能。