Skip to content

Commit 1d0e68f

Browse files
committed
Include $$typeof on inlined React elements
See facebook/react#4832.
1 parent 436ba9b commit 1d0e68f

File tree

17 files changed

+31
-9
lines changed

17 files changed

+31
-9
lines changed

packages/babel/src/transformation/file/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export default class File {
9292
"temporal-undefined",
9393
"temporal-assert-defined",
9494
"self-global",
95+
"typeof-react-element",
9596
"default-props",
9697
"instanceof",
9798

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(typeof Symbol === "function" && Symbol.for && Symbol.for("react.element")) || 0xeac7

packages/babel/src/transformation/transformers/optimisation/react.inline-elements.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export var visitor = {
6161
}
6262

6363
// metadata
64+
pushElemProp("$$typeof", file.addHelper("typeof-react-element"));
6465
pushElemProp("type", type);
6566
pushElemProp("ref", t.literal(null));
6667

packages/babel/test/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"use strict";
22

3+
var _typeofReactElement = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 60103;
4+
35
var _ref = {
6+
$$typeof: _typeofReactElement,
47
type: "foo",
58
ref: null,
69
props: {},
@@ -13,6 +16,7 @@ function render() {
1316
function render() {
1417
var text = getText();
1518
var _ref2 = {
19+
$$typeof: _typeofReactElement,
1620
type: "foo",
1721
ref: null,
1822
props: {
@@ -23,4 +27,4 @@ function render() {
2327
return function () {
2428
return _ref2;
2529
};
26-
}
30+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"use strict";
22

33
({
4+
$$typeof: babelHelpers.typeofReactElement,
45
type: Baz,
56
ref: null,
67
props: babelHelpers.defaultProps(Baz.defaultProps, {
78
foo: "bar"
89
}),
910
key: null
10-
});
11+
});
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"use strict";
22

33
({
4+
$$typeof: babelHelpers.typeofReactElement,
45
type: Baz,
56
ref: null,
67
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
78
key: null
8-
});
9+
});
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"use strict";
22

33
({
4+
$$typeof: babelHelpers.typeofReactElement,
45
type: "foo",
56
ref: null,
67
props: {
78
bar: "foo"
89
},
910
key: null
10-
});
11+
});
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"use strict";
22

33
({
4+
$$typeof: babelHelpers.typeofReactElement,
45
type: "foo",
56
ref: null,
67
props: {},
78
key: null
8-
});
9+
});

packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/key/expected.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22

33
({
4+
$$typeof: babelHelpers.typeofReactElement,
45
type: Foo,
56
ref: null,
67
props: babelHelpers.defaultProps(Foo.defaultProps, {}),
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"use strict";
22

33
({
4+
$$typeof: babelHelpers.typeofReactElement,
45
type: Foo,
56
ref: null,
67
props: babelHelpers.defaultProps(Foo.defaultProps, {
78
children: [bar, {
9+
$$typeof: babelHelpers.typeofReactElement,
810
type: Baz,
911
ref: null,
1012
props: babelHelpers.defaultProps(Baz.defaultProps, {}),
@@ -13,4 +15,4 @@
1315
className: "foo"
1416
}),
1517
key: null
16-
});
18+
});

0 commit comments

Comments
 (0)