[react] default props value

dev stefanCho·2021년 7월 7일
0

react

목록 보기
5/19

React에서는 props의 value를 따로 쓰지 않으면 boolean으로 보게 되어 있다.
(html5에서는 특정 attribute만 boolean을 갖는다.)

Default Props

class App extends React.Component {
  render() {
    return <MyComponent hasButton/>;
  }
}
// MyComponent내에서 this.props.hasButton은 true가 된다.

Ref

Docs: https://reactjs.org/docs/jsx-in-depth.html#props-default-to-true
Html5: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes#boolean_attributes

profile
Front-end Developer

0개의 댓글