Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
120
rated 0 times [  123] [ 3]  / answers: 1 / hits: 43005  / 7 Years ago, tue, may 30, 2017, 12:00:00

Why am I getting this error below? My statement ReactDOM.render(<App />, container); is 100% legit code.



My github repo: https://github.com/leongaban/react_starwars



enter



The app.js file



import react from 'react'
import ReactDom from 'react-dom'
import App from 'components/App'

require('index.html');

// Create app
const container = document.getElementById('app-container');

// Render app
ReactDOM.render(<App />, container);


The components/App file



import React from 'react'

const App = () =>
<div className='container'>
<div className='row'>

</div>
<div className='row'>

</div>
</div>;

export default App;


My webpack.config



const webpack = require('webpack');
const path = require('path');

module.exports = {
entry: [
'./src/app.js'
],
output: {
path: path.resolve(__dirname, './build'),
filename: 'app.bundle.js',
},
module: {
loaders: [
{
test: /.html$/,
loader: 'file-loader?name=[name].[ext]',
},
{
test: /.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
],
},
plugins: [
new webpack.NamedModulesPlugin(),
]
};

More From » reactjs

 Answers
16

Use this as your webpack config file



const webpack = require('webpack');
const path = require('path');

module.exports = {
entry: [
'./src/app.js'
],
output: {
path: path.resolve(__dirname, './build'),
filename: 'app.bundle.js',
},
module: {
loaders: [
{
test: /.html$/,
loader: 'file-loader?name=[name].[ext]',
},
{
test: /.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
},
],
},
plugins: [
new webpack.NamedModulesPlugin(),
]
};


You are missing the presets


[#57619] Friday, May 26, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
editha

Total Points: 564
Total Questions: 107
Total Answers: 109

Location: Finland
Member since Fri, Oct 21, 2022
2 Years ago
;