Skip to content

Tag: reactjs

react context is giving undefined object

In my react application I am trying to use context api. In my component I am importing the context but it is giving error that object can not destructure the property. I am trying to implement cart functionality in my app. I am using hooks. ImgContext.js ImageGrid.js Answer You are not providing a a default v…

Apply filters to a list and show data

Front-end: After return(): Service.js: Controller.js: So, this page of my web-app serves to show a list of all the companies saved in my database. I created a filter that allows you to show only those of a certain type, via findByType. I would like to insert other filters such as: findByRevenue, findByEmploye…

How to update nested array in React state?

I am trying to update my state so that a nested array gets emptied but the rest of the state stays the same. My state object looks like: And I the closest I get to working is: The console warning I get with this approach is: But how else is this possible? Many thanks 🙂 Answer The first problem I

dispatching actions on every render

I am dispatching action addProducts on every mount of the ProductList component whereas i want to dispatch the action one timeusing useEffect hook and store the data in the redux and then use it. Below are my actions file and ProductList component file. actions.js file ProductList.js component file Answer You…