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

315
Views
¿Cómo ejecutar la función principal desde el niño en reaccionar nativo?

Necesito ejecutar la función principal desde el elemento secundario que se importa. El componente secundario es mi vista de botón. Por favor, ayude a encontrar una solución en el archivo principal:

 export default function Home(props) { function test(){ alert("asd") } <CardheaderSlider name="All" /> <CardheaderSlider name="English" /> <CardheaderSlider name="Mathematics" /> <CardheaderSlider name="Science" /> <CardheaderSlider name="Languages" /> <CardheaderSlider name="Activity Books" /> <CardheaderSlider name="E-Training" /> }

Archivo CardheaderSlider

 export default class CardheaderSlider extends React.Component { render() { return ( <Pressable style={styles.button}> <Text style={{ color: "#fff", fontWeight: "bold" }}>{this.props.name}</Text> </Pressable> ) } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede agregar el atributo onPress en su hijo:

 export default class CardheaderSlider extends React.Component { render() { return ( <Pressable style={styles.button} onPress={() => this.props.onPress()}> <Text style={{ color: "#fff", fontWeight: "bold" }}>{this.props.name}</Text> </Pressable> ) }

Y llámalo como:

 <CardheaderSlider name="All" onPress={() => myFunction()}/>
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!