Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions src/content/learn/removing-effect-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -609,17 +609,6 @@ function ChatRoom({ roomId }) {

### Do you want to read a value without "reacting" to its changes? {/*do-you-want-to-read-a-value-without-reacting-to-its-changes*/}

<<<<<<< HEAD
<Canary>

**The `useEffectEvent` API is currently only available in React’s Canary and Experimental channels.**

[Learn more about React’s release channels here.](/community/versioning-policy#all-release-channels)

</Canary>

=======
>>>>>>> 11cb6b591571caf5fa2a192117b6a6445c3f2027
Suppose that you want to play a sound when the user receives a new message unless `isMuted` is `true`:

```js {3,10-12}
Expand Down Expand Up @@ -1264,25 +1253,6 @@ Is there a line of code inside the Effect that should not be reactive? How can y

<Sandpack>

<<<<<<< HEAD
```json package.json hidden
{
"dependencies": {
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
```

=======
>>>>>>> 11cb6b591571caf5fa2a192117b6a6445c3f2027
```js
import { useState, useEffect, useRef } from 'react';
import { useEffectEvent } from 'react';
Expand Down Expand Up @@ -1394,25 +1364,6 @@ Your Effect needs to read the latest value of `duration`, but you don't want it

<Sandpack>

<<<<<<< HEAD
```json package.json hidden
{
"dependencies": {
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
```

=======
>>>>>>> 11cb6b591571caf5fa2a192117b6a6445c3f2027
```js
import { useState, useEffect, useRef } from 'react';
import { FadeInAnimation } from './animation.js';
Expand Down
68 changes: 0 additions & 68 deletions src/content/learn/reusing-logic-with-custom-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -837,17 +837,6 @@ Every time your `ChatRoom` component re-renders, it passes the latest `roomId` a

### Passing event handlers to custom Hooks {/*passing-event-handlers-to-custom-hooks*/}

<<<<<<< HEAD
<Canary>

**The `useEffectEvent` API is currently only available in React’s Canary and Experimental channels.**

[Learn more about React’s release channels here.](/community/versioning-policy#all-release-channels)

</Canary>

=======
>>>>>>> 11cb6b591571caf5fa2a192117b6a6445c3f2027
As you start using `useChatRoom` in more components, you might want to let components customize its behavior. For example, currently, the logic for what to do when a message arrives is hardcoded inside the Hook:

```js {9-11}
Expand Down Expand Up @@ -1721,25 +1710,6 @@ html, body { min-height: 300px; }
}
```

<<<<<<< HEAD
```json package.json hidden
{
"dependencies": {
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
```

=======
>>>>>>> 11cb6b591571caf5fa2a192117b6a6445c3f2027
</Sandpack>

However, you didn't *have to* do that. As with regular functions, ultimately you decide where to draw the boundaries between different parts of your code. You could also take a very different approach. Instead of keeping the logic in the Effect, you could move most of the imperative logic inside a JavaScript [class:](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes)
Expand Down Expand Up @@ -2213,25 +2183,6 @@ It looks like your `useInterval` Hook accepts an event listener as an argument.

<Sandpack>

<<<<<<< HEAD
```json package.json hidden
{
"dependencies": {
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
```

=======
>>>>>>> 11cb6b591571caf5fa2a192117b6a6445c3f2027
```js
import { useCounter } from './useCounter.js';
import { useInterval } from './useInterval.js';
Expand Down Expand Up @@ -2287,25 +2238,6 @@ With this change, both intervals work as expected and don't interfere with each

<Sandpack>

<<<<<<< HEAD
```json package.json hidden
{
"dependencies": {
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
```

=======
>>>>>>> 11cb6b591571caf5fa2a192117b6a6445c3f2027

```js
import { useCounter } from './useCounter.js';
Expand Down