ProgrammingLang/React

[React] Hook- array useState 관리

jinkwon.kim 2023. 3. 8. 10:35
728x90
반응형

개요

React Hook 에서 사용되는 useState의 관리 방법을 정리 합니다. 

useState가 array 인경우 

추가 

https://bobbyhadz.com/blog/react-push-to-state-array

 

How to push an Element into a state Array in React | bobbyhadz

Use the spread syntax to push an element to a state array in React, e.g. `setNames(current => [...current, 'New'])`. The spread syntax (...) will unpack the existing elements of the state array into a new array where we can add other elements.

bobbyhadz.com

삭제

https://dev.to/collegewap/how-to-delete-an-item-from-the-state-array-in-react-kl

 

How to delete an item from the state array in React?

Have you started working on React recently and wanted to know the right way to delete an item from an...

dev.to

 

728x90
반응형

'ProgrammingLang > React' 카테고리의 다른 글

[React] cheatsheet  (0) 2023.07.06