일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- JSX
- Props
- event
- routes
- map
- Navigation
- node.js
- leetcode
- component
- c++
- UE5
- state
- axios
- treenode
- bit
- server
- 비트연산
- count
- priority_queue
- queue
- React
- array
- nodeJS
- Context
- MySQL
- DP
- BinaryTree
- route
- Callback
- css
- Today
- Total
목록array (2)
우사미 코딩

https://state-updates.vercel.app/ State Updates state-updates.vercel.app 참고 페이지 1. Array 1) 특정 index에 새로운 데이터 추가하기 2) 배열에서 특정값 제거하기 - filter함수 사용 2. Object Array 1) 특정 object의 value 변경하기 - map함수 사용 2) object에서 key제거하기 (...rest) 3) object에서 key추가하기
import { useState } from "react"; function getRandomAnimal(){ const animals = ['bird','cat','cow','dog','gator', 'horse']; return animals[Math.floor(Math.random() * animals.length)]; } function App(){ const[animals, setAnimals] = useState([]); const handleClick = () =>{ setAnimals([...animals, getRandomAnimal()]); console.log(animals); } return ( Add animal {animals} ); } export default App; lin..