const{} , const[] => 구조분해할당 (비구조화 할당)
const dhild = {
name: "철수",
age: 13,
school: "ddd초등학교"
}
const name = childe.name
const age = child.age
const school = child.school
const {naem, age, school} = child
const { data, loading } = useQuery(FETCH_BOARDS)
=> 리턴값이 객체
(data: ~~, loading: ~~)
const classmate = ["1번", "2번", "3번"]
const child1 = classmate[0]
const child2 = classmate[1]
const child3 = classmate[2]
=> const [child1, child2, child3] = classmate
const[state, setState] = useState("")
=> return 값이 배열 [데이터(state), 함수(setState)]
ex)
function useQuery(aaa(fetchBoards같은것들)) {
console.log(aaa + "로 데이터를 요철합니다")
const result = "철수"
return {data: result}
}
=>>>>
const { data } = useQuery("FETCH_BOARD")
// FETCH_BOARD로 데이터를 요청합니다
=> data >>>>> '철수'
function useState(aaa) {
const count = aaa
return [count, "count를 변경하는 함수"]
}
const [count, setCount] = useState(10)
==> // [10, 'count를 변경하는 함수']
굳이 구조분해 할당을 하지않아도 변수를 사용할 수 있음.
const aaa = useQuery(FETCH_BOARD)
=> //aaa.data = "철수"
const bbb = useState(10)
=> // bbb.[0] = "10"