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

144
Views
Is it possible to do prop drilling from React Class Component to Functional Component?

I am currently working some React Class Component Code and wanna do a props drilling to allow the child functional component call alert functions in the parent Component. Specifically, I am doing the following: In this class constructor, I made the binding: this.setPtbrRequestAlert = this.setPtbrRequestAlert.bind(this);

setPtbrRequestAlertFunction

And in the section where I pass down the props function, I did this: Props drilling from Parent to child

However, in the child component, props passed are destructured but I am not able to use them in the functional component as these props are not found. Can not find name

Can somebody explain what is wrong with this props drilling? Why am I not able to reference these values by desturturing them in the functional child component and if there is a way to address it?

I know somebody may wanna suggest refactor all the codes to functional component but I am trying not to mess around with Prod code right now. I want to gracefully implement new features with functional component and refactor old codes in the future gradually. Thanks in advance!

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

0

You've written code which is renaming the props inside the child component. When you do this:

({setAlertCallback: AlertCallbackFunction, userId: any}) => {

That's not doing typescript, that's doing destructuring with renaming. It's the equivalent of:

(props) => {
  let AlertCallbackFunction = props.setAlertCallback;
  let any = props.userId

So when you try to interact with setAlertCallback you can't, because you've renamed it AlertCallbackFunction instead.

You want do do:

({ setAlertCallback, userId }: {setAlertCallback: AlertCallbackFunction, userId: any}) => {
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!