Created
April 15, 2018 10:40
-
-
Save theKashey/c3114acaff041203e50e9a4912af0089 to your computer and use it in GitHub Desktop.
Table gDSFP
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
// base - https://github.com/reactjs/rfcs/pull/40#discussion_r180818891 | |
import memoize from "lodash.memoize"; | |
class Example { | |
getSortedData = memoize((list, sortFn) => list.slice().sort(sortFn)) | |
getPagedData = memoize((list, page) => list.slice(page*10, (page+1)*10)) | |
render() { | |
const sorted = this.getSortedData(this.props.data, this.props.sort); | |
const pages = this.getPagedData(sorted, this.props.page); | |
// Render with this.props, this.state, and derived values ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment