This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin; | |
| module.exports = { | |
| plugins: [new BundleAnalyzerPlugin()] | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const webpack = require("webpack"); | |
| module.exports = { | |
| entry: { | |
| client: "./src/index.js", | |
| vendor: ["react", "react-dom", "react-router", "react-router-dom"] | |
| }, | |
| plugins: [ | |
| new webpack.optimize.CommonsChunkPlugin({ | |
| name: "vendor", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const webpack = require("webpack"); | |
| const path = require("path"); | |
| const buildPath = path.resolve("build"); | |
| module.exports = { | |
| output: { | |
| path: buildPath, | |
| filename: "[name].[chunkhash:8].js", | |
| chunkFilename: "[name].[chunkhash:8].chunk.js" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // home.js | |
| import React from "react"; | |
| export default () => ( | |
| <div className="wrapper"> | |
| <h2>Home</h2> | |
| </div> | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // home-container.js | |
| import Loadable from "react-loadable"; | |
| import Spinner from "../Common/Spinner"; | |
| export default Loadable({ | |
| loader: () => import("./Home" /*webpackChunkName: 'home' */), | |
| loading: Spinner | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default class extends React.Component { | |
| shouldComponentUpdate(nextProps, nextState) { | |
| return true; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default class extends React.PureComponent { | |
| shouldComponentUpdate(nextProps, nextState) { | |
| return !( | |
| shallowEqual(nextProps, this.props) && shallowEqual(nextState, this.state) | |
| ); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const arr1 = [1, 2, 3]; | |
| const arr2 = [1, 2, 3]; | |
| arr1 === arr2; // false | |
| const obj1 = { foo: "bar" }; | |
| const obj2 = { foo: "bar" }; | |
| obj1 === obj2; // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| render() { | |
| return ( | |
| <ul> | |
| {this.props.todos.map(todo => ( | |
| <Todo todo={todo} onClick={() => this.props.onTodoClick(todo.id)} /> | |
| ))} | |
| </ul> | |
| ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Todo extends React.Component { | |
| render() { | |
| return ( | |
| <li className="todo" onClick={this.props.onClick}> | |
| {this.props.todo} | |
| </li> | |
| ); | |
| } | |
| } |