concept css in category react
appears as: CSS

This is an excerpt from Manning's book React in Action.
Another point worth making is about CSS. I’ve already covered the ways you work with inline styles in React, but CSS is also generally out of the scope of this book. For that reason, I’ve created all the styles you’ll need. Any UI markup you see has styles created for it. Some styles depend on certain types or hierarchies, so if you move different elements around or change CSS class names, you can expect the app to look broken. My aim is to give you one less thing to think about while learning React, but if you’re interested in playing around with the app’s styling, go right ahead.
Listing 13.3. Simple React Native example (App.js)
import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; #1 export default class App extends React.Component { constructor(props) { #2 super(props); this.state = { people: [] }; } async componentDidMount() { #3 const res = await fetch('https://swapi.co/api/people'); const { results } = await res.json(); this.setState(() => { return { people: results }; }); } render() { return ( <View style={styles.container}> #4 <Text style={{ color: '#fcd433', fontSize: 40, padding: 10 }}> A long time ago, in a Galaxy far, far away... </Text> <Text>Here are some cool people:</Text> {this.state.people.map(p => { #5 return ( <Text style={{ color: '#fcd433' }} key={p.name}> {p.name} </Text> ); })} </View> ); } } const styles = StyleSheet.create({ #6 container: { flex: 1, backgroundColor: '#000', alignItems: 'center', justifyContent: 'center' } }); #1 Unlike React, React Native comes with primitive components for your UI. #2 Constructor, state initialization, and lifecycle methods are the same in React and React Native #3 You can use modern JavaScript features like async/await in React Native apps too. #4 Even though styles appear similar in React Native, you’re not using CSS. #5 JSX expressions are the same in React Native and React #6 Creating a stylesheet in React Native requires use of its Stylesheet API to style your components. !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":1,\"ch\":70},{\"line\":1,\"ch\":72}],[{\"line\":47,\"ch\":0},{\"line\":47,\"ch\":2}],[{\"line\":4,\"ch\":70},{\"line\":4,\"ch\":72}],[{\"line\":48,\"ch\":0},{\"line\":48,\"ch\":2}],[{\"line\":10,\"ch\":70},{\"line\":10,\"ch\":72}],[{\"line\":49,\"ch\":0},{\"line\":49,\"ch\":2}],[{\"line\":21,\"ch\":70},{\"line\":21,\"ch\":72}],[{\"line\":50,\"ch\":0},{\"line\":50,\"ch\":2}],[{\"line\":26,\"ch\":70},{\"line\":26,\"ch\":72}],[{\"line\":51,\"ch\":0},{\"line\":51,\"ch\":2}],[{\"line\":38,\"ch\":68},{\"line\":38,\"ch\":70}],[{\"line\":52,\"ch\":0},{\"line\":52,\"ch\":2}]]"} !@%STYLE%@!