How to access a useState variable in a useSubscription
Here is my code, useSubscription can't access new values of a useState variable :
const [sessionChoose, setSessionChoose] = useState<ISession | undefined>();
useSubscription({
channel: "tentatives",
onLiveEvent: (dataTentative: any) => {
const tentative: ITentative = dataTentative.etudiantFaitNouvelleTentative;
if (tentative.idSession !== sessionChoose?.id) return;
console.log("ok");
}
})