const [data, setData] = useState(null)
useEffect(()=>{
setData({id:1, title:"hello world"})
},[])
useEffect(()=>{
//why data value is null?
Echo.join('ChatMessage').listen('ChatMessage',(res) => console. log (data))
//
Echo.join('ChatMessage').listen('ChatMessage',(res) => setData (oldData => {
console.log(oldData) // {id:1, title:"hello world"}
return oldData
}))
},[])
How can I call the state value of the changed data?
The existing state can only be called by using the set function. Is there any way to call it easily?