Frontend Development
Problem about infinite loop when calling the hook function useState in React
Today I tried to get data from the back end by calling a GET request, and then saved it to the state. But it caused an endless loop that kept sending requests. The code is as follows const [article, setArticle] = useState(); axios.get(url).then(({data}) => { setArticle(data) }) Solution: Use useEffect Read more…