일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- TS
- ESlint
- Promise
- 타입 좁히기
- tailwind
- webpack
- 무한 스크롤
- 태그된 유니온
- CI/CD
- recoil
- RTK Query
- SSR
- useAppDispatch
- map
- app router
- React
- dfs
- 결정 알고리즘
- 공변성
- Cypress
- async/await
- 투포인터
- 반공변성
- 리터럴 타입
- 호이스팅
- Jest
- 인터섹션
- autosize
- 이분 검색
- CORS
Archives
- Today
- Total
목록동적 input (1)
짧은코딩
동적으로 Input 추가, 삭제하기
필요한 변수 및 interface interface ItemInfo { id: number; name: string; values: string; } TypeScript라서 우선 데이터의 구조를 잡아줬다. const ItemId = useRef(1); const [itemInfos, setItemInfos] = useState([ { id: 0, name: "", values: "" }, ]); ItemId는 input이 동적으로 늘어감에 따라 각 Item에 부여할 ID이다. itemInfos는 각 아이템들을 저장하는 배열이다. 필요한 함수들 input 추가 함수 const addInput = useCallback(() => { const Item = { id: ItemId.current, name: "..
리액트
2022. 12. 23. 03:54