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

153
Views
In React how do you pass "this" to a functional component?

Say I have a class component function like so which accesses the props

myFunction() {
   console.log(this.props)
}

if this component the renders a functional component inside it and I pass it down like so:

<MyFunctionalComponent onChange={this.myFunction} />

this then breaks saying cannot read props of undefined presumably because the concept of "this" isn't in functional land

is there an easy way to fix this except for a big refactor? or passing props in as arguments rather than this.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You really answered your own question.

because you are working in a class Component, you have to use 'this.' to pass the method. What I would do is the following.

<MyFunctionalComponent onChange={() => this.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!