mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-10-26 23:32:02 +03:00
setState within componentWillMount uses internal property update (#2149)
Summary: Release notes: none As we're updating state on a final object, in this case `state`, ensure we use `hardModifyReactObjectPropertyBinding`. Unblocks https://github.com/facebook/prepack/pull/2137. Closes https://github.com/facebook/prepack/pull/2149 Reviewed By: hermanventer Differential Revision: D8584676 Pulled By: trueadm fbshipit-source-id: f23c77a5091b7c1023a48a5d29353bf9cdc06d65
This commit is contained in:
parent
18e69904d5
commit
93cd9a1d63
@ -23,7 +23,13 @@ import {
|
|||||||
} from "../values/index.js";
|
} from "../values/index.js";
|
||||||
import * as t from "babel-types";
|
import * as t from "babel-types";
|
||||||
import type { BabelNodeIdentifier } from "babel-types";
|
import type { BabelNodeIdentifier } from "babel-types";
|
||||||
import { flagPropsWithNoPartialKeyOrRef, getProperty, getValueFromFunctionCall, valueIsClassComponent } from "./utils";
|
import {
|
||||||
|
flagPropsWithNoPartialKeyOrRef,
|
||||||
|
getProperty,
|
||||||
|
getValueFromFunctionCall,
|
||||||
|
hardModifyReactObjectPropertyBinding,
|
||||||
|
valueIsClassComponent,
|
||||||
|
} from "./utils";
|
||||||
import { ExpectedBailOut, SimpleClassBailOut } from "./errors.js";
|
import { ExpectedBailOut, SimpleClassBailOut } from "./errors.js";
|
||||||
import { Get, Construct } from "../methods/index.js";
|
import { Get, Construct } from "../methods/index.js";
|
||||||
import { Properties } from "../singletons.js";
|
import { Properties } from "../singletons.js";
|
||||||
@ -219,15 +225,15 @@ export function createClassInstanceForFirstRenderOnly(
|
|||||||
if (stateToUpdate instanceof ObjectValue) {
|
if (stateToUpdate instanceof ObjectValue) {
|
||||||
let newState = new ObjectValue(realm, realm.intrinsics.ObjectPrototype);
|
let newState = new ObjectValue(realm, realm.intrinsics.ObjectPrototype);
|
||||||
objectAssignCall(realm.intrinsics.undefined, [newState, prevState]);
|
objectAssignCall(realm.intrinsics.undefined, [newState, prevState]);
|
||||||
|
newState.makeFinal();
|
||||||
|
|
||||||
for (let [key, binding] of stateToUpdate.properties) {
|
for (let [key, binding] of stateToUpdate.properties) {
|
||||||
if (binding && binding.descriptor && binding.descriptor.enumerable) {
|
if (binding && binding.descriptor && binding.descriptor.enumerable) {
|
||||||
let value = getProperty(realm, stateToUpdate, key);
|
let value = getProperty(realm, stateToUpdate, key);
|
||||||
Properties.Set(realm, newState, key, value, true);
|
hardModifyReactObjectPropertyBinding(realm, newState, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newState.makeFinal();
|
|
||||||
Properties.Set(realm, instance, "state", newState, true);
|
Properties.Set(realm, instance, "state", newState, true);
|
||||||
}
|
}
|
||||||
if (callback instanceof ECMAScriptSourceFunctionValue && callback.$Call) {
|
if (callback instanceof ECMAScriptSourceFunctionValue && callback.$Call) {
|
||||||
|
Loading…
Reference in New Issue
Block a user