Skip to content
Advertisement

Tag: use-effect

How to use useEffect and for loop to generate multiple JSX elements

I want to use useEffect and for-loop to generate multiple JSX elements but nothing is rendered in this case. warning code: “React Hook useEffect has a missing dependency: ‘renderInfoCard’. Either include it or remove the dependency array react-hooks/exhaustive-deps” Answer I wouldn’t put components in state (and you really shouldn’t mutate state either). Instead, wait for all the results to come

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 operator? Is so I thought that

How to generate data for the child component?

Here is the parent code: Here is the child code: The expected result is that: When the user picks a month from the MonthPicker, the parent component submit the select month and year to server. Get the result from the server and then send the result to the child component. The actual result is that the child components show its

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 could just dispatch the action in the component but in

Advertisement