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
Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article