Does Reactjs’s useEffect cause an infinite loop?
export const FoodContextProvider = (props) => { const [selectedFoods, setSelectedFoods] = useState([]); const [newFood, setNewFood] = useState({}); const [mode, setMode] = useState(null); const [length, setLength] = useState(selectedFoods.length); useEffect(() => { if (mode === "add") { const duplicate = selectedFoods.some((item) =>…