import missing useState in the useEffect markdown file (#7457)

This commit is contained in:
Sruthi Krishnakumar
2025-01-27 21:55:15 +05:30
committed by GitHub
parent a5aad0d5e9
commit 4d44167a43

View File

@@ -23,7 +23,7 @@ useEffect(setup, dependencies?)
Call `useEffect` at the top level of your component to declare an Effect:
```js
import { useEffect } from 'react';
import { useState, useEffect } from 'react';
import { createConnection } from './chat.js';
function ChatRoom({ roomId }) {
@@ -81,7 +81,7 @@ Some components need to stay connected to the network, some browser API, or a th
To [connect your component to some external system,](/learn/synchronizing-with-effects) call `useEffect` at the top level of your component:
```js [[1, 8, "const connection = createConnection(serverUrl, roomId);"], [1, 9, "connection.connect();"], [2, 11, "connection.disconnect();"], [3, 13, "[serverUrl, roomId]"]]
import { useEffect } from 'react';
import { useState, useEffect } from 'react';
import { createConnection } from './chat.js';
function ChatRoom({ roomId }) {