ngschaider / bier-in-aktion-webapp

0 stars 0 forks source link

set function needs cb as parameter #4

Closed cgimpl closed 2 years ago

cgimpl commented 2 years ago

https://github.com/ngschaider/bier-in-aktion-webapp/blob/476083165a7f5106f0f33366d9b193b9e11e2deb/src/components/ProductCardContainer.tsx#L11

ngschaider commented 2 years ago

I think you are mistaking a set-function returned from useState with the setState method from class-components. The latter will take a callback function but not with the useState hook. With functional components a useEffect hook is used when requiring an action to take place after the state got changed to trigger an additional rerender if needed.