Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !603

When JSX is used, automatically import 'react' appropriately

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/jayphelps/jsx into master Sep 08, 2016
  • Overview 5
  • Commits 1
  • Pipelines 0
  • Changes 6

Created by: jayphelps

Now if they use JSX, it will transparently import react and correctly reference the right createElement(). No more awkward import React from 'react';.

Before
import React from 'react';

const App = () => (
  <div>hello world</div>
);

export default App;
var _react = __webpack_require__(35);

var _react2 = _interopRequireDefault(_react);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var App = function App() {
  return (0, _react.createElement)(
    'div',
    null,
    'hello world'
  );
};

exports.default = App;
After
const App = () => (
  <div>hello world</div>
);

export default App;
var _react = __webpack_require__(35);

var App = function App() {
  return (0, _react.createElement)(
    "div",
    null,
    "hello world"
  );
};

exports.default = App;

Anyone I show this ability to so instantly says "omg why didn't I use this earlier", so I imagine it is a welcome addition; but perhaps some will say it's "too much magic"...but let's be real, JSX is magic.

I could not find a test suite for create-react-app; I assume there isn't currently a test suite for the cli/scripts?

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/jayphelps/jsx