this error appears when I test the start of a reaction
my folder structure is simple:
app folder index.html index.js home.js webpack.config.js dist folder bundle.js
index.html look like this
<!DOCTYPE html> <html> <head> <title>hello world app</title> <link rel="stylesheet" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src= "../dist/bundle.js"></script> </head> <body> <div id="app"></div> </body> </html>
index.js is as follows:
var React = require('react'); var ReactDOM = require('react-dom'); var Home = require('./Home'); ReactDOM.render( Home, document.getElementById('app'));
and home.js:
var React = require('react'); var Home = React.createClass({ render: function(){ return( <div> hello from home </div> ) } }); module.exports = Home;
I start compiling the code through this webpack configuration:
module.exports = { entry:[ "./app/index.js" ], output: { path: __dirname + '/dist', filename: "bundle.js" }, module: { loaders : [ {test: /\.js$/, exclude : /node_modules/, loader: "babel-loader", query: { presets: ['react'] } } ] } }
After compilation, I run the index.html file. And the error ReactDOM.render () appeared: Invalid component element .... What did I do wrong?
source share