I'm trying to fetch data from an API every time a user creates a new post. And I know that if you want to make the request happen when the data changes you can use this:
const [tweets, setTweets] = useState([])
useEffect(() => {
api.get('tweets').then(response => setTweets(response.data))
}, [tweets])
It works, and I don't need to refresh the page to see the new post that has been created. But when I go to Inspect in my app and then to Network, I can see that infinite amounts of GET requests happen, even if I specified the call only when the array changes. Can someone tell me how to solve it? (I don't know if it's normal to happen or something that I need to be worried about)