Last active
June 11, 2020 20:51
-
-
Save itaditya/16b869db68a14638253a83a4b2855933 to your computer and use it in GitHub Desktop.
Blog- Optimizing React apps with Memo
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
| --- a/src/App.js | |
| +++ b/src/App.js | |
| function Table(props) { | |
| console.log('render: Table'); | |
| // other old code | |
| } | |
| +const OptimizedTable = React.memo(Table); | |
| function App() { | |
| console.log('render: App'); | |
| return ( | |
| <div className={cn('app', `theme-${stateTheme}`)}> | |
| <main className="main"> | |
| <Picker activeHouseId={stateActiveHouseId} onChange={handleFilter} /> | |
| <p>List starts with {filteredCharacters[0].name}</p> | |
| - <Table charactersList={filteredCharacters} /> | |
| + <OptimizedTable charactersList={filteredCharacters} /> | |
| </main> | |
| </div> | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment