React native passing multiple styles from parent to child, component, which method is more used? What is the difference?
Rest parameter type, <Text style={{...styles.title, ...props.style}}>{props.children}
I also found this syntax here:
using array, <Text style={[styles.title, props.style]}>{props.children}
There are no differences between the two examples. However, the second way is the standard way to combine styles as mentioned in the react-native
documentation.
The
style
prop can be a plain old JavaScript object. That's 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.