class Counter extends Component {
constructor(props) {
super(props);
this.state = {
number : 0,
fixedNumber : 0
}
}
render() {
const {number, fixedNumber} = this.state
return (
<>
<h3>{fixedNumber}</h3>
<h1>{number}</h1>
<button onClick={() => {
this.setState({number : number + 1})
}}>
+1
</button>
</>
)
}
}
class Counter extends Component {
state = {
number : 0,
fixedNumber : 0
}
render() {
const {number, fixedNumber} = this.state
return (
<>
<h3>{fixedNumber}</h3>
<h1>{number}</h1>
<button onClick={() => {
this.setState({number : number + 1})
}}>
+1
</button>
</>
)
}
}
// import (보통 자동으로 들어옴)
import React, {useState} from 'react';
// use
let [count, setCount] = useState(0);
function App() {
return(
{count}
< button onClick = {()=>{setCount(count+1)}}>up!!< /button >
)
}
🌟 잘못된 부분에 대한 말씀은 언제나 저에게 큰 도움이 됩니다. 🌟
👍 감사합니다!! 👍