bradtraversy / proshop_mern

Shopping cart built with MERN & Redux
1.99k stars 1.18k forks source link

can't add 'product' dependency in ProductEditScreen useHook() #48

Closed saifulshihab closed 3 years ago

saifulshihab commented 3 years ago

Note: I clone this repo

When I add the product dependency in useEffect() it's just re-run the component multiple times. I don't know why it's not working, the same thing works in UserEditScreen. Please check this :) Line: https://github.com/bradtraversy/proshop_mern/blob/4f47ea707d06e60b72f06aea300fb2e0b135e60d/frontend/src/screens/ProductEditScreen.js#L53

It's showing this error: 'This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render. in ProductEditScreen (created by Context.Consumer)'

basir commented 3 years ago

clone the latest repo and try again. I do not see this issue on the latest repo. let me know if you have any issue.

saifulshihab commented 3 years ago

Solved! had a mistake in Reducer

basir commented 3 years ago

sounds good.