Last active
February 9, 2020 03:56
-
-
Save json2d/e7f65204cf271063cc7e29dd5f14a0b7 to your computer and use it in GitHub Desktop.
proposal to put state into callback scope through 'this'
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 entryByIdSelector = (state) => state.todos.entrybyId | |
const recentIdsSelector = (state) => state.todos.recentIds | |
const entrySelector = _.memoize( | |
(id) => createSelector( | |
entryByIdSelector, | |
(entryById) => entryById[id] | |
) | |
) | |
const recentSelector = createSelector( | |
recentIdsSelector, | |
function (ids) { | |
return ids.map( id => entrySelector(id)(this.state /* magic */ ) ) | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
...or just deal with a potential performance hit when doing it all in one
connect
🥇same high-level behavior