배열에서 객체배열로

이서현·2022년 6월 7일
0

reduce로 만들어 보는 중

// index.tsx
const nTotal = totalDate.reduce((a, b) => a.concat({ id: b, hello: 'hi' }), [])

역시나 타입문제였다.

  const nTotal = totalDate.reduce((a: object[], b) => a.concat({ id: b, hello: 'hi' }), [])

에러는 깔끔히 사라졌다.

profile
🌿💻💪🧠👍✨🎉

0개의 댓글