import React from 'react';
import ReactDOM from 'react-dom';
class Toggle extends React.Component {
constructor(props) {
super(props);
this.state = { toggle : false };
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
// todo
this.setState({ toggle : this.state.toggle?false:true });
}
render() {
return (
<button onClick={this.handleClick}>{this.state.toggle?"ON":"OFF"}</button>
);
}
}
ReactDOM.render(
<Toggle />,
document.getElementById('root')
);
'web > javascript' 카테고리의 다른 글
antd useRef current.focus (0) | 2022.06.14 |
---|---|
typescript onchange moment (0) | 2022.06.12 |
Promise then (0) | 2021.10.01 |
async await Promise.resolve (0) | 2020.07.20 |
simple padding zero (0) | 2020.02.27 |
댓글