React Native Styling
With React Native, you don't use a special language or syntax for defining styles. You just style your application using JavaScript. All of the core components accept a prop named style. The style names and values usually match how CSS works on the web, except names are written using camel casing, e.g backgroundColor rather than background-color. The style prop can be a plain old JavaScript object. That's the simplest and what we usually use for example code. You can also pass an array of styles - the last style in the array has precedence, so you can use this to inherit styles. As a component grows in complexity, it is often cleaner to use StyleSheet.create to define several styles in one place. Examples: const styles = StyleSheet . create ({ text : { fontSize : 20 , textAlign : ' center ' } }) function MyStyledText ({style, ... rest}) { return ( < Text style = {[ styles . text , style]} { ... rest} / > ) } ...
To get a clear idea of the lifecycle we will need to differentiate between the initial creation phase, where the component is created, and state and props changes triggered updates as well as the component unmoutings phase.
Initialization
State Changes
Props Changes
Unmounting