22 lines
559 B
TypeScript
22 lines
559 B
TypeScript
import React from 'react';
|
|
import { io } from "socket.io-client";
|
|
|
|
function App() {
|
|
const socket = io("http://localhost:3010");
|
|
const emitData = () => console.log(socket.emit("example-request", "custom-request"));
|
|
socket.on("example-response", (data) => console.log(`Received response in front end with data: ${data}`));
|
|
|
|
return (
|
|
<div className="App">
|
|
<header className="App-header">
|
|
<button onClick={emitData}>
|
|
Emit Data
|
|
</button>
|
|
Hello World! Front
|
|
</header>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default App;
|