I've been following a React guide which goes through setting up webpack and babel in my repo. I created a react element which will simply print out "Hello World", and then I use the ReactDOM.render method to add this element into the index.html file, but for some reason it's not being added in.
Here is my Index.js file:
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
export default class App extends React.component {
render() {
return(
<div>
Hello World
</div>
)
}
};
//////EDITED OUT <button /> for <App />
ReactDOM.render(<App />, document.getElementById("root"))
My index.html file:
<!DOCTYPE html>
<div id="root"></div>
My webpack.config.js file
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: "./App/index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js"
},
module: {
loaders: [
{
test: /\.(js)$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{ test: /\.css$/, use: [ 'style-loader', 'css-loader' ]}
]
},
plugins: [
new HtmlWebpackPlugin({
template: 'App/index.html'
})
]
}
My index.css:
body {
background: red;
}
My .babelrc file
{
"presets": ["es2015", "react"]
}
I've checked the dev console on my browser and it simply isn't showing the component enclosed inside the component in index.html file. Is there something additional I need for ReactDOM to push my react element into the DOM?
I've looked at others similar questions on stack but their problems ended up existing because of a typo, I've strained my eyes looking over my code and can't find any typos. I think there may be a step in the installation that I've skipped.