Skip to content

Instantly share code, notes, and snippets.

@itaditya
Last active June 11, 2020 20:51
Show Gist options
  • Select an option

  • Save itaditya/16b869db68a14638253a83a4b2855933 to your computer and use it in GitHub Desktop.

Select an option

Save itaditya/16b869db68a14638253a83a4b2855933 to your computer and use it in GitHub Desktop.
Blog- Optimizing React apps with Memo
--- 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