TypeError: Right side of assignment cannot be destructured on array map

I got:

TypeError: Right side of assignment cannot be destructured

error when I try to get array object's proprieties in one function in React. Do you know guys how to resolve this error? The array have only one object

 costs (){ return this.state.costs.map(({ rent, utilities, accounting, glass, contractor, gas}) => ({ rent: rent || 0, utilities: utilities || 0, accounting: accounting || 0, glass: glass || 0, contractor: contractor || 0, gas: gas || 0, }))[0] }
render () { const { rent, utilities, accounting, glass, contractor, gas} = this.costs(); console.log( rent, utilities, accounting, glass, contractor, gas) return (.........
6 Related questions 0 Object's property not available (undefined) inside Array.map 1 TypeError: Cannot read property 'map' of undefined Reactjs 0 error display when trying to destruct array in React JS Related questions 0 Object's property not available (undefined) inside Array.map 1 TypeError: Cannot read property 'map' of undefined Reactjs 0 error display when trying to destruct array in React JS 0 Cannot read property 'map' of undefined when destructing props 1 Map method keeps returning an array of objects causing an errror in React 0 Showing error when I use map function in ReactJs 0 Im not understanding why I'm recieving the error "Cannot read property 'map' of undefined" in React 0 React property is undefined when trying to use array map function 2 Uncaught TypeError: Cannot read properties of undefined (reading 'map') 0 I Can't Map Data in Array Load 7 more related questions Show fewer related questions Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like