Answer the question
In order to leave comments, you need to log in
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')
);
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question