I have a problem when using the react useState states, the problem is that I want the state to update every time my api changes it's value, but the state just changes when the component is loaded, here is the code of the part that I'm having trouble with:
const [partida,setPartida] = useState();
const getNumero = ()=>{
axios.get(`https://carta-rusa.herokuapp.com/routes/find/${localStorage.getItem('partidaId')}`)
.then(res=>{
setPartida(res.data.partida.jugadores.length)
})
.catch(err=>console.log(err));
}
useEffect(()=>{getNumero();},[])