Yes, you can actually use StyleSheet.create to create your own styles.
import React, { Component } from 'react'; import { StyleSheet, Text, View } from 'react-native'; class Header extends Component { constructor(props){ super(props); } render() { const { title, style } = this.props; const { header, text } = defaultStyle; const combineStyles = StyleSheet.flatten([header, style]); return ( <View style={ combineStyles }> <Text style={ text }> { title } </Text> </View> ); } } const defaultStyle = StyleSheet.create({ header: { justifyContent: 'center', alignItems: 'center', backgroundColor: '#fff', height: 60, paddingTop: 15, shadowColor: '#000', shadowOffset: { width: 0, height: 3 }, shadowOpacity: 0.4, elevation: 2, position: 'relative' }, text: { color: '#0d4220', fontSize: 16 } }); export default Header;
And then:
<Header title="HOME" style={ {backgroundColor: '#10f1f0'} } />
diegoprates 07 Oct '16 at 22:52 2016-10-07 22:52
source share