score:3

Accepted answer

based on the image you added, the error seems to occur on render function, so the componentdidmount never gets triggered for this exact reason.

try checking if this.props.productcategories exists before trying to use .map() on it. this should allow render function to run succesfully, and this will then trigger the componentdidmount as per react's lifecycle method order

this.props.productcategories && this.props.productcategories.map((pc, i) ...

also, try removing the export on your first row, keeping just the export default of your last row where you also make use of connect hoc, like:

class productcategory extends component { 

// ...

}


export default connect(mapstatetoprops, mapdispatchtoprops)(productcategory)

Related Query

More Query from same tag