import React, { useState, useEffect } from "react"; import { io } from "socket.io-client"; function useInput({ type }) { const [value, setValue] = useState(""); const input = ( setValue(e.target.value)} type={type} /> ); return [value, input]; } function App() { const [ENDPOINT, setEndpoint] = useInput({ type: "text" }); const [response, setResponse] = useState(""); const handleConnection = () => { // setEndpoint(); const socket = io(ENDPOINT); }; return ( <>
ENTER THE ENDPOINT
{setEndpoint} -> {ENDPOINT}It's
> ); } export default App;