Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

96
Visualizações
What's wrong with this implementation? I'm unable to override the style

I want to override the fontSize of my subheading text. I'm getting the style prop in my component. I've checked it by using console.log and it's fine. But my styles are not implementing. What's wrong with my code. Please help.

Here's the component called Subheading,

function SubHeadingText({children, style}) {
  return (
    <Text style={[{fontSize: style.fontSize}, styles.textSubHeading]}>
      {children}
    </Text>
  );
}

const styles = StyleSheet.create({
  textSubHeading: {
    fontSize: 19,
    color: colors.black,
  },
});

and here's I'm passing the style

<SubHeadingText style={{fontSize: 14}}>
    All fields are required to register with App.
</SubHeadingText>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Flip the order of the styles, they are applied in order and you override it with the constant stylesheet:

See React Native Style Docs:

You can also pass an array of styles - the last style in the array has precedence, so you can use this to inherit styles

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>
  );
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda