I tried to build a refresh button to refresh my react-table data, here is my code
const [data, setData] = useState([]);
const [loadingData, setLoadingData] = useState(true);
const [refreshData, setRefreshData] = useState(false);
const getData = async ()=>{
const response = await axios.get('http://localhost:5000/in-data')
setData(response.data)
setLoadingData(false);
}
useEffect(()=>{
getData()
},[refreshData])
Here is the button
<button
className="button"
type="button"
onClick={setRefreshData(!RefreshData)}
>
Refresh
</button>
The result is Error: Infinite Looping, reach the maximum number of re-render. Anyone know how to do it in the proper way?