Last active
March 2, 2018 06:49
-
-
Save theKashey/68a455d27ffbbe0e9d95ab1ca3543ca5 to your computer and use it in GitHub Desktop.
memoize-state cases
This file contains 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 addAandB = memoize( (a,b) => a + b ); | |
addAandB(1,1)// refresh | |
addAandB(1,1)// memoized | |
addAandB(1,2)// refresh |
This file contains 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 filterData = memoize( data => data.filter(item => item.selected) ) | |
filterData([{selected:true, value:1}, {selected: false, value: 2}]) // refresh | |
filterData([{selected:true, value:1}, {selected: false, value: 2}]) // memoized | |
filterData([{selected:true, value:1}, {selected: false, value: 3}]) // memoized!! | |
filterData([{selected:true, value:2}, {selected: false, value: 2}]) // refresh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment