I am new to react and have initialized a variable named socket inside the use effect hook. I am trying to access it in my return statement. However i cant seem to access it. I am not sure how to do it. Thanks in advance!
function SendSocketData(socket) {
socket.emit("hello", "world");
}
function App() {
useEffect(()=> {
let socket = io("http://localhost:3001",
);
},[]);
return (
<div className="App">
<button onClick={()=>SendSocketData(socket)}>Send Data </button>
</div>
);
}
export default App;