Skip to content

Commit

Permalink
Recompose
Browse files Browse the repository at this point in the history
  • Loading branch information
vasanthk committed Mar 25, 2017
1 parent b3896c4 commit 58fc31c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions perf-tips/02.recompose.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Use Recompose to memoize prop values
*
* @Reference:
* https://github.com/acdlite/recompose#composition
*/


// BAD
export default (props, context) => {
// ... do expensive compute on props ...
return <SomeComponent {...props} />
}


// GOOD
import { pure } from 'recompose';
// This won't be called when the props DONT change
export default pure((props, context) => {
// ... do expensive compute on props ...
return <SomeComponent someProp={props.someProp}/>
})

0 comments on commit 58fc31c

Please sign in to comment.