dan
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
1 additions and
1 deletions
-
src/content/learn/lifecycle-of-reactive-effects.md
|
@ -672,7 +672,7 @@ This may look like a React error, but really React is pointing out a bug in your |
|
|
To fix the bug, follow the linter's suggestion to specify `roomId` and `serverUrl` as dependencies of your Effect: |
|
|
To fix the bug, follow the linter's suggestion to specify `roomId` and `serverUrl` as dependencies of your Effect: |
|
|
|
|
|
|
|
|
```js {9} |
|
|
```js {9} |
|
|
function ChatRoom({ roomId }) { |
|
|
function ChatRoom({ roomId }) { // roomId is reactive |
|
|
const [serverUrl, setServerUrl] = useState('https://localhost:1234'); // serverUrl is reactive |
|
|
const [serverUrl, setServerUrl] = useState('https://localhost:1234'); // serverUrl is reactive |
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
const connection = createConnection(serverUrl, roomId); |
|
|
const connection = createConnection(serverUrl, roomId); |
|
|