mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Add back transitive freeze functions option
Adds back a mode to transitively freeze function expressions, independently from the mode to preserve existing manual memoization. This lets us experiment with a few variants: * Preserve existing memoization * Validate existing memoization with: * `enableAssumeHooksFollowRulesOfReact` && `enableTransitivelyFreezeFunctionExpressions` * `enableAssumeHooksFollowRulesOfReact` only * neither of those flags Note that `enableTransitivelyFreezeFunctionExpressions` alone probably doesn't make sense, it's more aggressive than `enableAssumeHooksFollowRulesOfReact` so we might as well try them together.
This commit is contained in:
@@ -354,7 +354,10 @@ class InferenceState {
|
||||
reason: reasonSet,
|
||||
});
|
||||
|
||||
if (this.#env.config.enablePreserveExistingMemoizationGuarantees) {
|
||||
if (
|
||||
this.#env.config.enablePreserveExistingMemoizationGuarantees ||
|
||||
this.#env.config.enableTransitivelyFreezeFunctionExpressions
|
||||
) {
|
||||
if (value.kind === "FunctionExpression") {
|
||||
for (const operand of eachInstructionValueOperand(value)) {
|
||||
this.reference(operand, Effect.Freeze, ValueReason.Other);
|
||||
|
||||
Reference in New Issue
Block a user