Mark hoisted react constant elements as #__PURE__ (#7372)
This commit is contained in:
committed by
GitHub
parent
d75a6b8468
commit
d283324f8a
@@ -1,4 +1,5 @@
|
||||
import { types as t } from "@babel/core";
|
||||
import annotateAsPure from "@babel/helper-annotate-as-pure";
|
||||
|
||||
export default function transformReactConstantElement(api, options) {
|
||||
const { allowMutablePropsOnTags } = options;
|
||||
@@ -101,7 +102,11 @@ export default function transformReactConstantElement(api, options) {
|
||||
path.traverse(immutabilityVisitor, state);
|
||||
|
||||
if (state.isImmutable) {
|
||||
path.hoist();
|
||||
const hoisted = path.hoist();
|
||||
|
||||
if (hoisted) {
|
||||
annotateAsPure(hoisted);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user