diff --git a/packages/babel-plugin-transform-react-jsx-self/src/index.js b/packages/babel-plugin-transform-react-jsx-self/src/index.js index 85113bca0c..2fd02a77ed 100644 --- a/packages/babel-plugin-transform-react-jsx-self/src/index.js +++ b/packages/babel-plugin-transform-react-jsx-self/src/index.js @@ -1,7 +1,6 @@ - - /** - * This adds {fileName, lineNumber} annotations to React component definitions - * and to jsx tag literals. +/** + * This adds a __self={this} JSX attribute to all JSX elements, which React will use + * to generate some runtime warnings. * * * == JSX Literals == @@ -17,10 +16,11 @@ const TRACE_ID = "__self"; export default function ({ types: t }) { let visitor = { - JSXOpeningElement(node) { + JSXOpeningElement({ node }) { const id = t.jSXIdentifier(TRACE_ID); - const trace = t.identifier("this"); - node.container.openingElement.attributes.push(t.jSXAttribute(id, t.jSXExpressionContainer(trace))); + const trace = t.thisExpression(); + + node.attributes.push(t.jSXAttribute(id, t.jSXExpressionContainer(trace))); } };