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

199
Visualizações
How do I “inherit” core component props in custom created components

I have created a custom component that I want to reuse multiple times throughout my app. The component is itself using a TouchableHighlight inside it.

I want the usage of the component to be able to pass through TouchableHighlight props without having to declare them separately inside the custom component.

A very simple example:

Component:

const CustomComponent = () => (
<TouchableHighlight>
<Text>Custom component</Text>
</TouchableHighlight>)

Usage:

<CustomComponent activeOpacity={0.5} underlayColor=“red” onPress={someAction} />

So to summarise, I’d like the TouchableHighlight to use activeOpacity, underlayColor, and onPress without having to single them out inside the component individually.

Hope that makes sense and I’ve explained it sufficiently.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can spread the props if you just want it to pass through.

const CustomComponent = (props) => (
<TouchableHighlight ...props>
<Text>Custom component</Text>
</TouchableHighlight>)
about 4 years ago · Juan Pablo Isaza Relatório

0

Try this:

const CustomComponent = ({touchableHighlightProps, ...otherProps}) => {
  return (
  <TouchableHighlight {...touchableHighlightProps}>
  <Text>Custom component</Text>
  </TouchableHighlight>
  )
}

Then the usage will be:

<CustomComponent touchableHighlightProps={touchableHighlightProps} />
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