반응형
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
- Props
- priority_queue
- nodeJS
- map
- count
- Callback
- Context
- queue
- React
- treenode
- event
- 비트연산
- c++
- BinaryTree
- UE5
- MySQL
- bit
- JSX
- route
- routes
- DP
- leetcode
- array
- state
- node.js
- server
- css
- Navigation
- axios
- component
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