-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Update useEffectEvent docs for canary #8025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Size changes📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 One Page Changed SizeThe following page changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this. |
src/content/learn/escape-hatches.md
Outdated
```js | ||
import { useState, useEffect } from 'react'; | ||
import { experimental_useEffectEvent as useEffectEvent } from 'react'; | ||
import { useEffectEvent as useEffectEvent } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { useEffectEvent as useEffectEvent } from 'react'; | |
import { useEffectEvent } from 'react'; |
and the rest
Bumps `useEffectEvent` from `@experimental` to `@canary`. Removes the `experimental_` prefix from the export. ## TODO - [ ] Update useEffectEvent reference page and Canary badging in docs: reactjs/react.dev#8025
Bumps `useEffectEvent` from `@experimental` to `@canary`. Removes the `experimental_` prefix from the export. ## TODO - [ ] Update useEffectEvent reference page and Canary badging in docs: reactjs/react.dev#8025 DiffTrain build for [8bb7241](8bb7241)
Bumps `useEffectEvent` from `@experimental` to `@canary`. Removes the `experimental_` prefix from the export. ## TODO - [ ] Update useEffectEvent reference page and Canary badging in docs: reactjs/react.dev#8025 DiffTrain build for [8bb7241](8bb7241)
|
||
useEffect(() => { | ||
onNavigate(url); | ||
}, [url]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the value of visitedUrl
the same as the url
since useEffectEvent
always closes over the latest values? So this feels like useless indirection.
A better example would be using it as an event handler and passing something as an argument that's not from props/state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shows a mix of reactive and nonreactive values. So visitedUrl
and url
are the same, but using the url
in the effect allows us to log on each render that url
changed, without worrying about logging when numberOfItems
changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to maybe explicitly say that in the text. Ie explain the resulting behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still seeing a lot of references to experimental_useEffectEvent
e.g src/content/learn/removing-effect-dependencies.md
. The sandboxes can also be updated to canary
. Makes it easier for me to ship everything as stable with a simple grep
Whoops. That was a pending comment that wasn't supposed to go into this approval. |
Bumps `useEffectEvent` from `@experimental` to `@canary`. Removes the `experimental_` prefix from the export. ## TODO - [ ] Update useEffectEvent reference page and Canary badging in docs: reactjs/react.dev#8025
Canary change in facebook/react#34610