mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-08-17 10:30:32 +03:00
Fix bug with unknown arrays during React reconciliation (#2251)
Summary: Release notes: none Fixes a bug with `valueIsFactoryClassComponent` not taking into account unknown arrays. Pull Request resolved: https://github.com/facebook/prepack/pull/2251 Differential Revision: D8834128 Pulled By: trueadm fbshipit-source-id: 01b337b3036fa3831f8d46bf1a25e2cd06971667
This commit is contained in:
parent
8b75241959
commit
a94f15e6f3
@ -197,7 +197,7 @@ export function valueIsLegacyCreateClassComponent(realm: Realm, value: Value): b
|
||||
}
|
||||
|
||||
export function valueIsFactoryClassComponent(realm: Realm, value: Value): boolean {
|
||||
if (value instanceof ObjectValue) {
|
||||
if (value instanceof ObjectValue && !ArrayValue.isIntrinsicAndHasWidenedNumericProperty(value)) {
|
||||
return To.ToBooleanPartial(realm, Get(realm, value, "render"));
|
||||
}
|
||||
return false;
|
||||
|
@ -166,6 +166,10 @@ it("Handle mapped arrays 2", () => {
|
||||
runTest(__dirname + "/FunctionalComponents/array-map2.js");
|
||||
});
|
||||
|
||||
it("Handle mapped arrays 3", () => {
|
||||
runTest(__dirname + "/FunctionalComponents/array-map3.js");
|
||||
});
|
||||
|
||||
it("Handle mapped arrays from Array.from", () => {
|
||||
runTest(__dirname + "/FunctionalComponents/array-from.js");
|
||||
});
|
||||
|
23
test/react/FunctionalComponents/array-map3.js
Normal file
23
test/react/FunctionalComponents/array-map3.js
Normal file
@ -0,0 +1,23 @@
|
||||
var React = require("react");
|
||||
|
||||
function App(props) {
|
||||
var items = Array.from(props.items);
|
||||
|
||||
var nested = function(item) {
|
||||
return item;
|
||||
};
|
||||
|
||||
return items.map(nested);
|
||||
}
|
||||
|
||||
App.getTrials = function(renderer, Root) {
|
||||
let items = [0, 0];
|
||||
renderer.update(<Root items={items} />);
|
||||
return [["simple render array map", renderer.toJSON()]];
|
||||
};
|
||||
|
||||
if (this.__optimizeReactComponentTree) {
|
||||
__optimizeReactComponentTree(App);
|
||||
}
|
||||
|
||||
module.exports = App;
|
@ -2616,6 +2616,74 @@ ReactStatistics {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Handle mapped arrays 3: (JSX => JSX) 1`] = `
|
||||
ReactStatistics {
|
||||
"componentsEvaluated": 1,
|
||||
"evaluatedRootNodes": Array [
|
||||
Object {
|
||||
"children": Array [],
|
||||
"message": "",
|
||||
"name": "App",
|
||||
"status": "ROOT",
|
||||
},
|
||||
],
|
||||
"inlinedComponents": 0,
|
||||
"optimizedNestedClosures": 1,
|
||||
"optimizedTrees": 1,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Handle mapped arrays 3: (JSX => createElement) 1`] = `
|
||||
ReactStatistics {
|
||||
"componentsEvaluated": 1,
|
||||
"evaluatedRootNodes": Array [
|
||||
Object {
|
||||
"children": Array [],
|
||||
"message": "",
|
||||
"name": "App",
|
||||
"status": "ROOT",
|
||||
},
|
||||
],
|
||||
"inlinedComponents": 0,
|
||||
"optimizedNestedClosures": 1,
|
||||
"optimizedTrees": 1,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Handle mapped arrays 3: (createElement => JSX) 1`] = `
|
||||
ReactStatistics {
|
||||
"componentsEvaluated": 1,
|
||||
"evaluatedRootNodes": Array [
|
||||
Object {
|
||||
"children": Array [],
|
||||
"message": "",
|
||||
"name": "App",
|
||||
"status": "ROOT",
|
||||
},
|
||||
],
|
||||
"inlinedComponents": 0,
|
||||
"optimizedNestedClosures": 1,
|
||||
"optimizedTrees": 1,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Handle mapped arrays 3: (createElement => createElement) 1`] = `
|
||||
ReactStatistics {
|
||||
"componentsEvaluated": 1,
|
||||
"evaluatedRootNodes": Array [
|
||||
Object {
|
||||
"children": Array [],
|
||||
"message": "",
|
||||
"name": "App",
|
||||
"status": "ROOT",
|
||||
},
|
||||
],
|
||||
"inlinedComponents": 0,
|
||||
"optimizedNestedClosures": 1,
|
||||
"optimizedTrees": 1,
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Handle mapped arrays from Array.from: (JSX => JSX) 1`] = `
|
||||
ReactStatistics {
|
||||
"componentsEvaluated": 1,
|
||||
|
Loading…
Reference in New Issue
Block a user