mixins • More Javascripty • More to type • Less structured • Existing component that is extended • Mixins not supported • More Englishy • Less to type • More structured React.Component
the browser We need ‘webpack’ to bundle our files into a single .js file linked to the html client and ‘webpack-dev-server’ to run the local with support for hot- reloading.
{ path: './dist', filename: 'bundle.js', publicPath: '/' }, devServer: { inline: true, contentBase: './dist' }, webpack.config.js 1 2 3 1. The React app 2. Output path for compiled bundle file 3. Name of the bundle (to be included as a script in index.html)
/(node_modules)/, loader: 'babel', query: { presets: ['es2015', 'react'] } } ] } } 1 2 3 1. Tells web pack to exclude node_modules folder 2. Name of the loader (required to transpile code) 3. Presets for the loader (Babel) to enable us to transpile es6/es2015 code and React JSX
id='main'></div> <script src="/bundle.js"></script> </body> </html> 1 2 1. Main element where React app will be rendered 2. Link to bundle script (compiled by webpack)