O'Reilly logo

React Native By Example by Richard Kho

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

With StyleSheet, within the same file

This is how a component accesses a StyleSheet created in the same file:

class Tasks extends Component {   render () {     return (       <View style = { styles.container }>         <Text style = { styles.welcome }>           Welcome to React Native!         </Text>       </View>     )   } } const styles = StyleSheet.create({   container: {     flex: 1,     justifyContent: 'center',     alignItems: 'center',     backgroundColor: '#F5FCFF'   },   welcome: {     fontSize: 20,     textAlign: 'center',     margin: 10   } )}; 

This is much better. We're moving our styles into an object we can reference without having to rewrite the same inline styles over and over. However, the problem we face is an extraordinarily long file with a lot of application logic, where a future ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required