import { useState, useEffect } from 'react' import reactLogo from './assets/react.svg' import viteLogo from '/vite.svg' import './App.css' import useWebSocket from 'react-use-websocket'; const API_URL = window.wing.env.API_URL; const WS_URL = window.wing.env.WS_URL; function App() { const [count, setCount] = useState("0"); const incrementCount = async () => { const response = await fetch(`${API_URL}/counter`, { method: "POST" }); setCount(await response.text()); } const updateCount = async () => { const response = await fetch(`${API_URL}/counter`); setCount(await response.text()); } useWebSocket(WS_URL, { onMessage: () => { updateCount(); } }); useEffect(() => { updateCount(); }, []); return ( <>
Edit src/App.tsx and save to test HMR
Click on the Vite and React logos to learn more
> ) } export default App;