Skip to content
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

Test StrictEffects in react-dom #28951

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Apr 29, 2024

Working in render but broken in hydrateRoot.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Apr 29, 2024
@react-sizebot
Copy link

react-sizebot commented Apr 29, 2024

Comparing: 190cc99...044e6d4

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.66 kB 6.66 kB +0.05% 1.82 kB 1.82 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.67 kB 6.67 kB +0.05% 1.83 kB 1.83 kB
facebook-www/ReactDOM-prod.classic.js = 591.11 kB 591.11 kB = 103.94 kB 103.94 kB
facebook-www/ReactDOM-prod.modern.js = 567.33 kB 567.33 kB = 100.34 kB 100.34 kB
test_utils/ReactAllWarnings.js Deleted 64.26 kB 0.00 kB Deleted 16.02 kB 0.00 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js Deleted 64.26 kB 0.00 kB Deleted 16.02 kB 0.00 kB

Generated by 🚫 dangerJS against 044e6d4

@eps1lon eps1lon force-pushed the strict-effects branch 2 times, most recently from 845ebfa to acd5fcc Compare April 29, 2024 16:19
container.innerHTML = ReactDOMServer.renderToString(element);

await act(() => {
ReactDOMClient.hydrateRoot(container, element);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uses mountChildFibers which has side-effect tracking disabled. Side-effect tracking sets the PlacementDEV flag. Since PlacementDEV is never set here, we never double invoke:

if (fiber.flags & PlacementDEV) {
setCurrentDebugFiberInDEV(fiber);
if (isInStrictMode) {
doubleInvokeEffectsOnFiber(
root,
fiber,
(fiber.mode & NoStrictPassiveEffectsMode) === NoMode,
);
}
resetCurrentDebugFiberInDEV();
} else {

But then it's not clear yet why we need this flag at all. Shouldn't we double invoke regardless of whether something was placed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants