When implementing the hook code from here
https://blog.logrocket.com/patterns-for-data-fetching-in-react-981ced7e5c56/
I get the following warning, what does this actually mean?
./src/components/Users.tsx Line 20:6: React Hook useEffect has a missing dependency: 'data.users'. Either include it or remove the dependency array. You can also replace multiple useState variables with useReducer if 'setData' needs the current value of 'data.users' react-hooks/exhaustive-deps
code:
import React, { useEffect, useState } from "react";
import axios from "axios";
const USER_SERVICE_URL = "https://jsonplaceholder.typicode.com/users";
export function List() {
const [data, setData] = useState({ users: [], isFetching: false });
useEffect(() => {
const fetchUsers = async () => {
try {
setData({ users: data.users, isFetching: true });
const response = await axios.get(USER_SERVICE_URL);
setData({ users: response.data, isFetching: false });
} catch (e) {
console.log(e);
setData({ users: data.users, isFetching: false });
}
};
fetchUsers();
}, []);
console.log(data)