Skip to content

Commit

Permalink
Configure Dynamic Feature Flags for React Native (#28527)
Browse files Browse the repository at this point in the history
## Summary

This PR is a subset of #28425,
which only includes the feature flags that will be configured as
dynamic.

The following list summarizes the feature flag changes:

* RN FB
  * Change to Dynamic
    * consoleManagedByDevToolsDuringStrictMode
    * enableAsyncActions
    * enableDeferRootSchedulingToMicrotask
    * enableRenderableContext
    * useModernStrictMode

## How did you test this change?

Ran the following successfully:

```
$ yarn test
$ yarn flow native
$ yarn flow fabric
```

DiffTrain build for commit 706d95f.
  • Loading branch information
yungsters committed Mar 9, 2024
1 parent ec2c0e0 commit 96bfe1e
Show file tree
Hide file tree
Showing 18 changed files with 5,215 additions and 1,002 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<50de4881bc1e7323607d21cae81406f7>>
* @generated SignedSource<<6d931d2de9a1892cd33381697c43409f>>
*/

"use strict";
Expand All @@ -16,6 +16,8 @@ if (__DEV__) {
(function () {
"use strict";

var dynamicFlags = require("ReactNativeInternalFeatureFlags");

// ATTENTION
// When adding new symbols to this file,
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
Expand All @@ -38,9 +40,12 @@ if (__DEV__) {
var REACT_CACHE_TYPE = Symbol.for("react.cache");

// NOTE: There are no flags, currently. Uncomment the stuff below if we add one.
// the exports object every time a flag is read.

var enableRenderableContext = dynamicFlags.enableRenderableContext;
// The rest of the flags are static for better dead code elimination.
var enableDebugTracing = false;
var enableScopeAPI = false;
var enableRenderableContext = false;
var enableLegacyHidden = false;
var enableTransitionTracing = false;

Expand Down Expand Up @@ -71,8 +76,8 @@ if (__DEV__) {
type.$$typeof === REACT_LAZY_TYPE ||
type.$$typeof === REACT_MEMO_TYPE ||
type.$$typeof === REACT_CONTEXT_TYPE ||
type.$$typeof === REACT_PROVIDER_TYPE ||
enableRenderableContext ||
(!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) ||
(enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) ||
type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
// types supported by any Flight configuration anywhere since
// we don't know which Flight build this will end up being used
Expand Down Expand Up @@ -114,12 +119,16 @@ if (__DEV__) {
return $$typeofType;

case REACT_CONSUMER_TYPE:
if (enableRenderableContext) {
return $$typeofType;
}

// Fall through

case REACT_PROVIDER_TYPE: {
return $$typeofType;
}
case REACT_PROVIDER_TYPE:
if (!enableRenderableContext) {
return $$typeofType;
}

// Fall through

Expand All @@ -135,8 +144,12 @@ if (__DEV__) {

return undefined;
}
var ContextConsumer = REACT_CONTEXT_TYPE;
var ContextProvider = REACT_PROVIDER_TYPE;
var ContextConsumer = enableRenderableContext
? REACT_CONSUMER_TYPE
: REACT_CONTEXT_TYPE;
var ContextProvider = enableRenderableContext
? REACT_CONTEXT_TYPE
: REACT_PROVIDER_TYPE;
var Element = REACT_ELEMENT_TYPE;
var ForwardRef = REACT_FORWARD_REF_TYPE;
var Fragment = REACT_FRAGMENT_TYPE;
Expand All @@ -148,12 +161,16 @@ if (__DEV__) {
var Suspense = REACT_SUSPENSE_TYPE;
var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
function isContextConsumer(object) {
{
if (enableRenderableContext) {
return typeOf(object) === REACT_CONSUMER_TYPE;
} else {
return typeOf(object) === REACT_CONTEXT_TYPE;
}
}
function isContextProvider(object) {
{
if (enableRenderableContext) {
return typeOf(object) === REACT_CONTEXT_TYPE;
} else {
return typeOf(object) === REACT_PROVIDER_TYPE;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<db70fee50d49f5366bc39dfb803ccafb>>
* @generated SignedSource<<f4f9eb9ce7783ae0921b56d253c4faad>>
*/

"use strict";
var REACT_ELEMENT_TYPE = Symbol.for("react.element"),
var dynamicFlags = require("ReactNativeInternalFeatureFlags"),
REACT_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
Expand All @@ -26,6 +27,7 @@ var REACT_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen"),
REACT_CACHE_TYPE = Symbol.for("react.cache"),
enableRenderableContext = dynamicFlags.enableRenderableContext,
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
function typeOf(object) {
if ("object" === typeof object && null !== object) {
Expand All @@ -47,8 +49,9 @@ function typeOf(object) {
case REACT_MEMO_TYPE:
return object;
case REACT_CONSUMER_TYPE:
if (enableRenderableContext) return object;
case REACT_PROVIDER_TYPE:
return object;
if (!enableRenderableContext) return object;
default:
return $$typeof;
}
Expand All @@ -58,8 +61,13 @@ function typeOf(object) {
}
}
}
exports.ContextConsumer = REACT_CONTEXT_TYPE;
exports.ContextProvider = REACT_PROVIDER_TYPE;
var ContextProvider = enableRenderableContext
? REACT_CONTEXT_TYPE
: REACT_PROVIDER_TYPE;
exports.ContextConsumer = enableRenderableContext
? REACT_CONSUMER_TYPE
: REACT_CONTEXT_TYPE;
exports.ContextProvider = ContextProvider;
exports.Element = REACT_ELEMENT_TYPE;
exports.ForwardRef = REACT_FORWARD_REF_TYPE;
exports.Fragment = REACT_FRAGMENT_TYPE;
Expand All @@ -71,10 +79,14 @@ exports.StrictMode = REACT_STRICT_MODE_TYPE;
exports.Suspense = REACT_SUSPENSE_TYPE;
exports.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
exports.isContextConsumer = function (object) {
return typeOf(object) === REACT_CONTEXT_TYPE;
return enableRenderableContext
? typeOf(object) === REACT_CONSUMER_TYPE
: typeOf(object) === REACT_CONTEXT_TYPE;
};
exports.isContextProvider = function (object) {
return typeOf(object) === REACT_PROVIDER_TYPE;
return enableRenderableContext
? typeOf(object) === REACT_CONTEXT_TYPE
: typeOf(object) === REACT_PROVIDER_TYPE;
};
exports.isElement = function (object) {
return (
Expand Down Expand Up @@ -125,7 +137,8 @@ exports.isValidElementType = function (type) {
(type.$$typeof === REACT_LAZY_TYPE ||
type.$$typeof === REACT_MEMO_TYPE ||
type.$$typeof === REACT_CONTEXT_TYPE ||
type.$$typeof === REACT_PROVIDER_TYPE ||
(!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) ||
(enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) ||
type.$$typeof === REACT_FORWARD_REF_TYPE ||
type.$$typeof === REACT_CLIENT_REFERENCE ||
void 0 !== type.getModuleId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<db70fee50d49f5366bc39dfb803ccafb>>
* @generated SignedSource<<f4f9eb9ce7783ae0921b56d253c4faad>>
*/

"use strict";
var REACT_ELEMENT_TYPE = Symbol.for("react.element"),
var dynamicFlags = require("ReactNativeInternalFeatureFlags"),
REACT_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
Expand All @@ -26,6 +27,7 @@ var REACT_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen"),
REACT_CACHE_TYPE = Symbol.for("react.cache"),
enableRenderableContext = dynamicFlags.enableRenderableContext,
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
function typeOf(object) {
if ("object" === typeof object && null !== object) {
Expand All @@ -47,8 +49,9 @@ function typeOf(object) {
case REACT_MEMO_TYPE:
return object;
case REACT_CONSUMER_TYPE:
if (enableRenderableContext) return object;
case REACT_PROVIDER_TYPE:
return object;
if (!enableRenderableContext) return object;
default:
return $$typeof;
}
Expand All @@ -58,8 +61,13 @@ function typeOf(object) {
}
}
}
exports.ContextConsumer = REACT_CONTEXT_TYPE;
exports.ContextProvider = REACT_PROVIDER_TYPE;
var ContextProvider = enableRenderableContext
? REACT_CONTEXT_TYPE
: REACT_PROVIDER_TYPE;
exports.ContextConsumer = enableRenderableContext
? REACT_CONSUMER_TYPE
: REACT_CONTEXT_TYPE;
exports.ContextProvider = ContextProvider;
exports.Element = REACT_ELEMENT_TYPE;
exports.ForwardRef = REACT_FORWARD_REF_TYPE;
exports.Fragment = REACT_FRAGMENT_TYPE;
Expand All @@ -71,10 +79,14 @@ exports.StrictMode = REACT_STRICT_MODE_TYPE;
exports.Suspense = REACT_SUSPENSE_TYPE;
exports.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
exports.isContextConsumer = function (object) {
return typeOf(object) === REACT_CONTEXT_TYPE;
return enableRenderableContext
? typeOf(object) === REACT_CONSUMER_TYPE
: typeOf(object) === REACT_CONTEXT_TYPE;
};
exports.isContextProvider = function (object) {
return typeOf(object) === REACT_PROVIDER_TYPE;
return enableRenderableContext
? typeOf(object) === REACT_CONTEXT_TYPE
: typeOf(object) === REACT_PROVIDER_TYPE;
};
exports.isElement = function (object) {
return (
Expand Down Expand Up @@ -125,7 +137,8 @@ exports.isValidElementType = function (type) {
(type.$$typeof === REACT_LAZY_TYPE ||
type.$$typeof === REACT_MEMO_TYPE ||
type.$$typeof === REACT_CONTEXT_TYPE ||
type.$$typeof === REACT_PROVIDER_TYPE ||
(!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) ||
(enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) ||
type.$$typeof === REACT_FORWARD_REF_TYPE ||
type.$$typeof === REACT_CLIENT_REFERENCE ||
void 0 !== type.getModuleId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25677,7 +25677,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-canary-71c4699de-20240308";
var ReactVersion = "18.3.0-canary-706d95f48-20240308";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9147,7 +9147,7 @@ var devToolsConfig$jscomp$inline_1016 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-71c4699de-20240308",
version: "18.3.0-canary-706d95f48-20240308",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1194 = {
Expand Down Expand Up @@ -9178,7 +9178,7 @@ var internals$jscomp$inline_1194 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-71c4699de-20240308"
reconcilerVersion: "18.3.0-canary-706d95f48-20240308"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1195 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9575,7 +9575,7 @@ var devToolsConfig$jscomp$inline_1058 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-71c4699de-20240308",
version: "18.3.0-canary-706d95f48-20240308",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1235 = {
Expand Down Expand Up @@ -9606,7 +9606,7 @@ var internals$jscomp$inline_1235 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-71c4699de-20240308"
reconcilerVersion: "18.3.0-canary-706d95f48-20240308"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1236 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<0d68343aed9ab27512ef97b5ce8c038e>>
* @generated SignedSource<<e8fc1f0235d7e4a937828eef96c3d9d7>>
*/

"use strict";
Expand Down Expand Up @@ -107,11 +107,11 @@ if (__DEV__) {
// the exports object every time a flag is read.

var enableComponentStackLocations =
dynamicFlags.enableComponentStackLocations;
dynamicFlags.enableComponentStackLocations,
enableRenderableContext = dynamicFlags.enableRenderableContext;
// The rest of the flags are static for better dead code elimination.
var enableDebugTracing = false;
var enableScopeAPI = false;
var enableRenderableContext = false;
var enableLegacyHidden = false;
var enableTransitionTracing = false;

Expand Down Expand Up @@ -188,21 +188,30 @@ if (__DEV__) {
}

switch (type.$$typeof) {
case REACT_PROVIDER_TYPE: {
var provider = type;
return getContextName(provider._context) + ".Provider";
}
case REACT_PROVIDER_TYPE:
if (enableRenderableContext) {
return null;
} else {
var provider = type;
return getContextName(provider._context) + ".Provider";
}

case REACT_CONTEXT_TYPE:
var context = type;

{
if (enableRenderableContext) {
return getContextName(context) + ".Provider";
} else {
return getContextName(context) + ".Consumer";
}

case REACT_CONSUMER_TYPE: {
return null;
}
case REACT_CONSUMER_TYPE:
if (enableRenderableContext) {
var consumer = type;
return getContextName(consumer._context) + ".Consumer";
} else {
return null;
}

case REACT_FORWARD_REF_TYPE:
return getWrappedName(type, type.render, "ForwardRef");
Expand Down Expand Up @@ -339,8 +348,8 @@ if (__DEV__) {
type.$$typeof === REACT_LAZY_TYPE ||
type.$$typeof === REACT_MEMO_TYPE ||
type.$$typeof === REACT_CONTEXT_TYPE ||
type.$$typeof === REACT_PROVIDER_TYPE ||
enableRenderableContext ||
(!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) ||
(enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) ||
type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
// types supported by any Flight configuration anywhere since
// we don't know which Flight build this will end up being used
Expand Down
Loading

0 comments on commit 96bfe1e

Please sign in to comment.