-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Closed
Labels
Description
Summary
In the first code snippet on this page, useState is called but is not imported in the snippet.
Suggest to improve as:
import { useEffect, useState } from 'react';
import { createConnection } from './chat.js';
function ChatRoom({ roomId }) {
const [serverUrl, setServerUrl] = useState('https://localhost:1234');
useEffect(() => {
const connection = createConnection(serverUrl, roomId);
connection.connect();
return () => {
connection.disconnect();
};
}, [serverUrl, roomId]);
// ...
}Page
https://react.dev/reference/react/useEffect#useeffect
Details
No response