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

166
Views
How to access props from a component that extends another component in React?

I have 3 components:

-Component A
    -Component B
        -Component C extends Component B

I'm passing a function as props from Component A to Component B and want to call the function in Component C.

I've tried added:

constructor(props) {
   super(props);
   this.props.validationsFunc = this.props.validationsFunc.bind(this);
}

and variations with/without props on either side of the bind in Component B. But when I try calling this.props.validationsFunc() in Component C, I get the error saying it is not a function.

class ComponentA extends PureComponent {
    const validationsFunc = () => {
        console.log('hi');
    };
    <ComponentB validationsFunc={validationsFunc} />
}


class ComponentB extends PureComponent {
   static propTypes = {
      validationsFunc: PropTypes.func
   };

   constructor(props){
      super(props);
      this.props.validationsFunc = this.props.validationsFunc.bind(this)
   }
}

   
class ComponentC extends ComponentB {
    this.props.validationsFunc();
}

How do I access this function in Component C without directly passing props to it?

about 4 years ago · Juan Pablo Isaza
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!