Reputation: 31
I'm currently trying to understand some JavaScript code in an App.js file for my react native app. I want to know if the code of<AppLoading/> <View>
components are considered HTML code or JavaScript code?
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/>
);
}
}
Upvotes: 0
Views: 78
Reputation: 172
It's a syntax extension to Javascript called JSX. You can read about it here.
You can think about it more or less like regular HTML, but with a few important syntax differences (such as replacing class
attributes with className
, requiring a parent element if there's multiple siblings, etc.) and the ability to inject JS expressions inside curly brackets.
Upvotes: 2