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
| // An example of an action | |
| const action = { | |
| type: "WITHDRAW_MONEY", | |
| amount: "$10,000" | |
| } | |
| // A basic reducer. Takes in two parameters: state, and action. | |
| const reducer = (state, action) => { | |
| return 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 Description = ({ description }) => { | |
| return ( | |
| <p> | |
| <span className="faint">I am</span> a {description} | |
| </p> | |
| ); | |
| } | |
| ... |
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 Description = ({ description }) => { | |
| return ( | |
| <p> | |
| <I /> | |
| <Am /> | |
| <A /> | |
| <Profession profession={description} /> | |
| </p> | |
| ); | |
| }; |
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
| import React, {Component, PureComponent} from "react" | |
| //before | |
| class I extends Component { | |
| render() { | |
| return <span className="faint">I </span>; | |
| } | |
| //after | |
| class I extends PureComponent { |
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 Description = ({ description }) => { | |
| return ( | |
| <p> | |
| <I /> | |
| <Am /> | |
| <A /> | |
| <Profession profession={description} /> | |
| </p> | |
| ); | |
| }; |
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 i = { | |
| value: "i" | |
| }; |
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 I extends PureComponent { | |
| render() { | |
| return <span className="faint">{this.props.i.value} </span>; | |
| } | |
| } |
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 Description extends Component { | |
| render() { | |
| const i = { | |
| value: "i" | |
| }; | |
| return ( | |
| <p> | |
| <I i={i} /> | |
| <Am /> | |
| <A /> |
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() { | |
| <div onClick={() => {//do something here}} | |
| } | |
| ... |
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:() ={ | |
| } | |
| render() { | |
| <div onClick={this.handleClick} | |
| } | |
| ... |