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 |
Tags
- reat if문
- React
- Math.sqrt()
- indexOf()
- charAt()
- slice()
- new Date()
- useEffect()
- Number()
- 항해99솔직후기 #항해99장점 #항해99단점 #부트캠프추천
- 3진수
- useRef()
- sort()
- 차집합
- repeat()
- 소수점 올림내림
- substring()
- Eventlitener
- getday()
- isNaN()
- Math.floor()
- 교집합
- jsx반복문
- includes()
- parseInt()
- setDate
- useState()
- map()
- toUpperCase()
- filter()
Archives
- Today
- Total
개발자로 전향중
Redux-Toolkit TypeScript 여러개의 객체를 배열 추가할때 본문
interface basketInfoProps {
clothes: string;
index: number;
}
interface basketproductProps {
basketInfo: basketInfoProps[];
}
타입 정하기
basketproduct: {
basketInfo: [{ clothes: "", index: 0 }],
},
initialState
basketproduct: (state, action: PayloadAction<basketproductProps>) => {
state.basketproduct.basketInfo = [
...state.basketproduct.basketInfo,
...action.payload.basketInfo,
];
},
createSlice
dispatch(
basketproduct({
basketInfo: [{ clothes: clothesInfo, index: index }],
})
);
dispatch 부분
배열에 객체를 넣는것은 기본인데 추가 삭제 수정이 의외로 까다롭다..
'React' 카테고리의 다른 글
Buffer image 데이터 base64으로 만들기 (0) | 2023.02.01 |
---|---|
TypeScript 환경변수 설정하고 싶을때 (0) | 2022.12.02 |
React 체크박스 여러개 체크할 때 체크 value (0) | 2022.11.02 |
react 표 만들고 싶을 때 참고 (0) | 2022.10.26 |
react hook form 사용 예시 and 자동 전화번호 하이픈 (1) | 2022.10.06 |