Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda