Skip to content

Tag: use-effect

How to better setup fetch with useEffect?

Im learning JS and React and I came to the code example below and some parts I don’t understand properly. The second .then is inside useUffect is this ok, or it’s better to be in getData func? Also in render there is data**?**.map and I don’t understand why we need ?, is this ternary operato…

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…