Update (1) 썸네일형 리스트형 [React] Create, Update, Delete 1. Create content = ( { // topics에 id, title, body 추가하기 const newTopic = { id: nextId, title: _title, body: _body }; const newTopics = [...topics]; newTopics.push(newTopic); setTopics(newTopics); setNextId(nextId + 1); }} > ); 배열의 상태를 변경시킬 때는 1) newValue = {...value} → ...을 통해 똑같은 배열을 복사한 newValue를 만든다 2) newValue 변경 → 복사된 배열을 변경시킨다 3) setValue(newValue) → 컴포넌트를 다시 실행시켜 변경된 내용으로 배열을 만든다. 2. Upda.. 이전 1 다음