setState part1

Wonju·2022년 1월 6일
0

React.useState() 는 초기값을 설정할 수 있는 함수

const data = React.useState()
console.log(data)
// [undefined, f] 출력
// undefined 는 data값이고
// f 는 data를 바꿀 때 사용하는 함수
// 즉 초기값과 그 값을 바꾸는 함수임
const food = [potato, tomato]
const [x,y] = food
// x= potato, y=tomato
// 위와 같은 방법(ES6 Destructing문법)으로 값을 할당 가능
profile
안녕하세여

0개의 댓글