일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- notFound()
- Babel
- next13 head
- React 고급안내서
- codingtest
- Javascript
- React 공식문서
- getUTCDate
- react hook
- RTK Query
- Nextjs React 18
- Next13
- react
- React18
- Programmers
- react-helmet
- CSS
- React 고급 안내서
- React 18
- Render Props
- background: url
- hook
- context
- React API 참고서
- background setInterval
- background setttimeout
- 고급안내서
- Nextjs
- React 18 Nextjs
- background tab
Archives
- Today
- Total
akjfal
Uncaught TypeError: Cannot assign to read only propery '0' of obejct '[object Array]' 본문
react/react 에러
Uncaught TypeError: Cannot assign to read only propery '0' of obejct '[object Array]'
akjfal 2019. 11. 23. 12:58
배열을 직접 수정하려고 하면 이러한 오류가 발생한다.
Error while sorting array of objects Cannot assign to read only property '2' of object '[object Array]'
I'm having array of objects where object looks like this (values change): { stats: { hp: 2, mp: 0, defence: 4, agility: 11, speed: 6, streng...
stackoverflow.com
해결법)
1. 배열을 잘랐다가 다시 합치기
2.
const tempOption = tempProduct.data.option.map((item, index) => {
if(index !== arraynum){
return item
}
return{
...item,
[e.target.name]: e.target.value
}
})
map함수를 통해서 재 생성