Skip to content

Instantly share code, notes, and snippets.

@theKashey
Last active April 16, 2018 00:52
Show Gist options
  • Save theKashey/fc2af683030aa125aa2b600b17179706 to your computer and use it in GitHub Desktop.
Save theKashey/fc2af683030aa125aa2b600b17179706 to your computer and use it in GitHub Desktop.
Table + MemoizedFlow
// base - https://github.com/reactjs/rfcs/pull/40#discussion_r180818891
import {MemoizedFlow} from "react-memoize";
class Example {
getSortedData = (list, sortFn) => list.slice().sort(sortFn)
getPagedData = (list, page) => list.slice(page*10, (page+1)*10))
render() {
return (
<MemoizedFlow
input={this.props}
flow = [
({data, sort}) => ({ data: this.getSortedData(data, sort)}),
({data, page}) => ({ data: this.getPagedData(sorted, page)});
]
>
{ ({data}) => /* Render with this.props, this.state, and derived values ..*/ }
</MemoizedFlow>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment