반응형
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- routes
- css
- route
- Context
- component
- Navigation
- React
- leetcode
- JSX
- priority_queue
- MySQL
- queue
- axios
- count
- DP
- node.js
- 비트연산
- BinaryTree
- c++
- Props
- bit
- Callback
- treenode
- map
- state
- server
- event
- array
- nodeJS
- UE5
Archives
- Today
- Total
목록setArray (1)
우사미 코딩
[React] state - 배열 초기화, 새로운 요소 추가하기
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..
React
2023. 6. 23. 14:24