V
V
Vyacheslav Lebedev2016-02-08 23:07:31
React
Vyacheslav Lebedev, 2016-02-08 23:07:31

Gulp + React + es2015 + babel?

Good evening!
I deal with a bunch: Gulp + React + es2015 + babel.
The gulp config is simple - I run all jsx through babel with a preset in .babrlrc:
"presets": ["es2015", "react"]
And I got an error in the browser:
require is not defined
Help me figure it out. I want to write things like this and make them work in the browser :)

import React from 'react';
import ReactDom from 'react-dom';

class CommentBox extends React.Component {
  render() {
    return (
      <div className="commentBox">
        Hello, world! I am a CommentBox.
      </div>
    );
  }
}

ReactDOM.render(
  <CommentBox />,
  document.getElementById('app')
);

Where and what am I doing wrong?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Lebedev, 2016-02-09
@slavikse

Earned. Only without imports.
Before that, react.js was in a separate file.
All combined into one and earned.
Missing babel-plugin-transform-es2015-modules-commonjs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question