I have this code
const [magicValue, setMagicValue] = useState([]) // assume that the value is now ["1"]
useEffect(() => {
const socket = socketIOClient(ENDPOINT)
socket.on("webhook", (data) => {
console.log(magicValue) // this will always be []
})
}, [])
The problem is that I seem to always have the magicValue as [] even if the state ["1"]. I even create a button to log that indeed the state is updated to ["1"], but for some reason, in the useEffect I get []