📜  react native socket io - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:15.646000             🧑  作者: Mango

代码示例1
import React, { useState, useEffect } from "react";
import socketIOClient from "socket.io-client";
const ENDPOINT = "http://127.0.0.1:4001";

function App() {
  const [response, setResponse] = useState("");

  useEffect(() => {
    const socket = socketIOClient(ENDPOINT);
    socket.on("FromAPI", data => {
      setResponse(data);
    });
  }, []);

  return (
    

It's

); } export default App;