I noticed one interesting thing in react native. I thought that const and let does not support hoisting in ES6. How is it possible to use const styles above its define?
render() {
const { repos } = this.state;
const reposList = repos.map((rep, index) => {
return (
<Text>{rep.name}</Text>
)
});
return (
<View style={styles.container}> <-- styles should not be defined
{reposList}
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
Is it because of hoisting mechanism in React Native?