I have this code
const [messages, setMessages] = useState([]);
and
useEffect(() => { socket.current.on("newMessa