일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- react-helmet
- context
- background setttimeout
- Nextjs
- Javascript
- Next13
- React 공식문서
- hook
- Nextjs React 18
- background: url
- React API 참고서
- RTK Query
- Programmers
- codingtest
- 고급안내서
- getUTCDate
- React 18
- CSS
- React18
- next13 head
- Render Props
- background tab
- React 18 Nextjs
- react hook
- Babel
- background setInterval
- notFound()
- React 고급 안내서
- React 고급안내서
- react
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함수를 통해서 재 생성
'react > react 에러' 카테고리의 다른 글
Comments