Quiero anular el tamaño de fuente de mi texto de subtítulo. Obtengo el accesorio de estilo en mi componente. Lo he comprobado usando console.log y está bien. Pero mis estilos no se están implementando. ¿Qué le pasa a mi código? Por favor ayuda.
Aquí está el componente llamado Subtítulo,
function SubHeadingText({children, style}) { return ( <Text style={[{fontSize: style.fontSize}, styles.textSubHeading]}> {children} </Text> ); } const styles = StyleSheet.create({ textSubHeading: { fontSize: 19, color: colors.black, }, });y aquí estoy pasando el estilo
<SubHeadingText style={{fontSize: 14}}> All fields are required to register with App. </SubHeadingText>Voltee el orden de los estilos, se aplican en orden y lo anula con la hoja de estilo constante:
Ver React Native Style Docs :
También puede pasar una matriz de estilos: el último estilo de la matriz tiene prioridad, por lo que puede usar esto para heredar estilos.
function SubHeadingText({children, style}) { return ( <Text style={[ styles.textSubHeading, // Needs to be applied first so next line overrides {fontSize: style.fontSize}, // Will override styles.textSubHeading fontSize ]}> {children} </Text> ); }