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
| handleClick = todoId => { | |
| this.setState({ | |
| [todoId]: { clicked: 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
| constructor(props) { | |
| super(props); | |
| this.handleClick = this.handleClick.bind(this); | |
| } |
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.handleClick.bind(this)} | |
| /> | |
| ))} | |
| </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 { | |
| handleClick = e => { | |
| this.props.onClick(this.props.todo.id); | |
| }; | |
| render() { | |
| return ( | |
| <li className="todo" onClick={this.handleClick}> | |
| {this.props.todo} | |
| </li> |
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> | |
| ); | |
| } | |
| } |
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
| 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
| 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
| 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
| // home-container.js | |
| import Loadable from "react-loadable"; | |
| import Spinner from "../Common/Spinner"; | |
| export default Loadable({ | |
| loader: () => import("./Home" /*webpackChunkName: 'home' */), | |
| loading: Spinner | |
| }); |