■ HTML / JSP
JS Bin
■ JS(ES6/Babel)
class Counter extends React.Component{ constructor(props) { super(props); this.state= { value: 0 }; this.handleClick = this.handleClick.bind(this); } handleClick() { this.setState({ value: this.state.value+1 }); } render() { return (); } } class App extends React.Component { render() { return ({this.state.value}
); } } ReactDOM.render( I am React.js , document.getElementById('root'));
※ 대문자 변경
<app>I am React.js</app> → <App>I am React.js</App>
<codelab> → <Codelab>
<counter> → <Counter>
※ 맨 마지막 <counter/> 삭제
'Developer > React.js' 카테고리의 다른 글
[Tutorial] Props (0) | 2018.01.22 |
---|---|
[Tutorial] JSX (0) | 2018.01.22 |