Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!