[Code Example] Passing data through props in reactJS

Total
0
Shares

Learn how you can pass data from one component to another through props in react js. Here we have declared two class components – Board and Square. We are passing data from Board class to the Square class.

Board.js

class Board extends React.Component {
  renderSquare(i) {
    return <Square value={i} />;
  }
}

Square.js

class Square extends React.Component {
  render() {
    return (
      <button className="square">
        {this.props.value}
      </button>
    );
  }
}

Source: ReactJs Docs

Sign Up for Our Newsletters

Get only the best articles delivered to your mail

You May Also Like