Skip to content

Enable the StrictEffects flag for OSS builds #21590

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const debugRenderPhaseSideEffectsForStrictMode = __DEV__;

// Helps identify code that is not safe for planned Offscreen API and Suspense semantics;
// this feature flag only impacts StrictEffectsMode.
export const enableStrictEffects = false;
export const enableStrictEffects = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export const enableStrictEffects = true;
export const enableStrictEffects = __DEV__;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could do this but there's a small inconsistency in that the WWW version re-exports a GK which does not have a DEV check. I'd rather have them all consistent. Currently I think we always check for __DEV__ in the source anyway before any behavioral changes. So I'd propose either:

  1. Keep it true
  2. Make it __DEV__ and change WWW feature flag to be __DEV__ && FeatureFlagsWWW.enableStrictEffects

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes more sense to compare to other flags within this feature flags file rather than www. So this would be more like debugRenderPhaseSideEffectsForStrictMode right above it.

Copy link
Contributor

@bvaughn bvaughn May 31, 2021

Choose a reason for hiding this comment

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

Currently I think we always check for __DEV__ in the source anyway before any behavioral changes.

Yeah, but this is to enable static dead code elimination in production builds even if there's a dynamic flag (like in www). I think the feature flags still generally use __DEV__ or __PROFILING__ to be explicit. :)

Copy link
Collaborator Author

@gaearon gaearon May 31, 2021

Choose a reason for hiding this comment

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

I think it makes more sense to compare to other flags within this feature flags file rather than www.

I'm thinking of a situation where we add some behavior difference in the source without checking __DEV__ before it (by mistake). Then, if WWW and OSS flags diverge in this way, you'd see the different behavior in production on WWW than in production in OSS. That seems like a risky divergence.

Copy link
Contributor

@bvaughn bvaughn May 31, 2021

Choose a reason for hiding this comment

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

Then let's change the OSS www export too.

There's good reason to keep the extra static __DEV__ wrapper (mentioned above) and I think there's also value in keeping the feature flags more scoped/explicit about DEV-only features.


// If TRUE, trees rendered with createRoot will be StrictEffectsMode.
// If FALSE, these trees will be StrictLegacyMode.
Expand Down