dryben / daily

무슨 생각을 해... 그냥 하는거지
0 stars 0 forks source link

react tutorial #11

Open dryben opened 4 years ago

dryben commented 4 years ago

class & function

https://reactjs.org/tutorial/tutorial.html#function-components In React, function components are a simpler way to write components that only contain a render method and don’t have their own state.

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