Saturday, 5 October 2024

React - Prop Drilling

 Prop Drilling -  Passing the props from parent to Child or nested child for multiple components is props drilling


Coding Example :



Output:



Passing data from Child to Parent using Callback functions


Output:

Output After Button click:




Super(props) - Its used inside the constructor 
    It will initiate the parent's constructor method and allows the component to inherit methods from its parent (React.Component).

e.g.
class Header extends React.Component {
  constructor(props) {
    super(props);
    this.state = {favoritecolor: "red"};
  }
}





No comments:

Post a Comment