Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 3 additions & 3 deletions src/content/learn/escape-hatches.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ This is not ideal. You want to re-connect to the chat only if the `roomId` has c
```json package.json hidden
{
"dependencies": {
"react": "experimental",
"react-dom": "experimental",
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest",
"toastify-js": "1.12.0"
},
Expand All @@ -471,7 +471,7 @@ This is not ideal. You want to re-connect to the chat only if the `roomId` has c

```js
import { useState, useEffect } from 'react';
import { experimental_useEffectEvent as useEffectEvent } from 'react';
import { useEffectEvent } from 'react';
import { createConnection, sendMessage } from './chat.js';
import { showNotification } from './notifications.js';

Expand Down
32 changes: 17 additions & 15 deletions src/content/learn/removing-effect-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,13 @@ 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*/}

<Wip>
<Canary>

This section describes an **experimental API that has not yet been released** in a stable version of React.
**The `useEffectEvent` API is currently only available in React’s Canary and Experimental channels.**

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

</Canary>

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

Expand Down Expand Up @@ -1262,8 +1264,8 @@ Is there a line of code inside the Effect that should not be reactive? How can y
```json package.json hidden
{
"dependencies": {
"react": "experimental",
"react-dom": "experimental",
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest"
},
"scripts": {
Expand All @@ -1277,7 +1279,7 @@ Is there a line of code inside the Effect that should not be reactive? How can y

```js
import { useState, useEffect, useRef } from 'react';
import { experimental_useEffectEvent as useEffectEvent } from 'react';
import { useEffectEvent } from 'react';
import { FadeInAnimation } from './animation.js';

function Welcome({ duration }) {
Expand Down Expand Up @@ -1389,8 +1391,8 @@ Your Effect needs to read the latest value of `duration`, but you don't want it
```json package.json hidden
{
"dependencies": {
"react": "experimental",
"react-dom": "experimental",
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest"
},
"scripts": {
Expand All @@ -1405,7 +1407,7 @@ Your Effect needs to read the latest value of `duration`, but you don't want it
```js
import { useState, useEffect, useRef } from 'react';
import { FadeInAnimation } from './animation.js';
import { experimental_useEffectEvent as useEffectEvent } from 'react';
import { useEffectEvent } from 'react';

function Welcome({ duration }) {
const ref = useRef(null);
Expand Down Expand Up @@ -1825,8 +1827,8 @@ Another of these functions only exists to pass some state to an imported API met
```json package.json hidden
{
"dependencies": {
"react": "experimental",
"react-dom": "experimental",
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest",
"toastify-js": "1.12.0"
},
Expand Down Expand Up @@ -1907,7 +1909,7 @@ export default function App() {

```js src/ChatRoom.js active
import { useState, useEffect } from 'react';
import { experimental_useEffectEvent as useEffectEvent } from 'react';
import { useEffectEvent } from 'react';

export default function ChatRoom({ roomId, createConnection, onMessage }) {
useEffect(() => {
Expand Down Expand Up @@ -2120,8 +2122,8 @@ As a result, the chat re-connects only when something meaningful (`roomId` or `i
```json package.json hidden
{
"dependencies": {
"react": "experimental",
"react-dom": "experimental",
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest",
"toastify-js": "1.12.0"
},
Expand Down Expand Up @@ -2189,7 +2191,7 @@ export default function App() {

```js src/ChatRoom.js active
import { useState, useEffect } from 'react';
import { experimental_useEffectEvent as useEffectEvent } from 'react';
import { useEffectEvent } from 'react';
import {
createEncryptedConnection,
createUnencryptedConnection,
Expand Down
32 changes: 17 additions & 15 deletions src/content/learn/reusing-logic-with-custom-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -837,11 +837,13 @@ 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*/}

<Wip>
<Canary>

This section describes an **experimental API that has not yet been released** in a stable version of React.
**The `useEffectEvent` API is currently only available in React’s Canary and Experimental channels.**

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

</Canary>

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:

Expand Down Expand Up @@ -985,7 +987,7 @@ export default function ChatRoom({ roomId }) {

```js src/useChatRoom.js
import { useEffect } from 'react';
import { experimental_useEffectEvent as useEffectEvent } from 'react';
import { useEffectEvent } from 'react';
import { createConnection } from './chat.js';

export function useChatRoom({ serverUrl, roomId, onReceiveMessage }) {
Expand Down Expand Up @@ -1070,8 +1072,8 @@ export function showNotification(message, theme = 'dark') {
```json package.json hidden
{
"dependencies": {
"react": "experimental",
"react-dom": "experimental",
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest",
"toastify-js": "1.12.0"
},
Expand Down Expand Up @@ -1666,7 +1668,7 @@ export default function App() {

```js src/useFadeIn.js active
import { useState, useEffect } from 'react';
import { experimental_useEffectEvent as useEffectEvent } from 'react';
import { useEffectEvent } from 'react';

export function useFadeIn(ref, duration) {
const [isRunning, setIsRunning] = useState(true);
Expand Down Expand Up @@ -1719,8 +1721,8 @@ html, body { min-height: 300px; }
```json package.json hidden
{
"dependencies": {
"react": "experimental",
"react-dom": "experimental",
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest"
},
"scripts": {
Expand Down Expand Up @@ -2208,8 +2210,8 @@ It looks like your `useInterval` Hook accepts an event listener as an argument.
```json package.json hidden
{
"dependencies": {
"react": "experimental",
"react-dom": "experimental",
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest"
},
"scripts": {
Expand Down Expand Up @@ -2252,7 +2254,7 @@ export function useCounter(delay) {

```js src/useInterval.js
import { useEffect } from 'react';
import { experimental_useEffectEvent as useEffectEvent } from 'react';
import { useEffectEvent } from 'react';

export function useInterval(onTick, delay) {
useEffect(() => {
Expand All @@ -2279,8 +2281,8 @@ With this change, both intervals work as expected and don't interfere with each
```json package.json hidden
{
"dependencies": {
"react": "experimental",
"react-dom": "experimental",
"react": "canary",
"react-dom": "canary",
"react-scripts": "latest"
},
"scripts": {
Expand Down Expand Up @@ -2324,7 +2326,7 @@ export function useCounter(delay) {

```js src/useInterval.js active
import { useEffect } from 'react';
import { experimental_useEffectEvent as useEffectEvent } from 'react';
import { useEffectEvent } from 'react';

export function useInterval(callback, delay) {
const onTick = useEffectEvent(callback);
Expand Down
Loading