Closed lily0125 closed 1 year ago
history does not work anymore its useNavigate now!
The most obvious solution to the error would be to add the obj
variable to the dependencies array of the useEffect hook.
const [address, setAddress] = useState({country: '', city: ''});
// 👇️ objects/arrays are different on re-renders const obj = {country: 'Chile', city: 'Santiago'};
useEffect(() => { setAddress(obj); console.log('useEffect called');
When run npm run build for frontend, I got following errors:
Compiled with warnings.
./src/screens/ProductScreen.js Line 44:6: React Hook useEffect has a missing dependency: 'product._id'. Either include it or remove the dependency array react-hooks/exhaustive-deps
./src/screens/OrderScreen.js Line 77:6: React Hook useEffect has missing dependencies: 'history' and 'userInfo'. Either include them or remove the dependency array react-hooks/exhaustive-deps how to fix that ?