문제
()번째 순서
()안에 들어가는 숫자를 + 1 이 되게 만들어라
App컴포넌트를 만들어줍니다
그 안에 카운터 상태를 만들어줍니다
const App = () => {
const [counter, setCounter] = React.useState(1);
console.log('234234');
return(
<div>
<Title>{counter}번째 순서</Title>
</div>
);
}
생성을 했을때에 부르는 함수 -> handleFormSubmit();
함수내용 ↓
count Form = () => {
function handleFormSubmit() {
setCounter(counter + 1);
}
}
함수내용을 보면 안에 counter 와 setCounter의 내용이 없어서 counter + 1을 못하고 있다
해결방법
- const Form = ({handleFormSubmit}) => {
}
Form /
props넘겨준후 상태
div
<Form handleFormSubmit= {handleFormSubmit}>/div