diff --git a/README.md b/README.md index 7d016a3..4561477 100644 --- a/README.md +++ b/README.md @@ -25,15 +25,15 @@ Could change the way you did `componentWillReceiveProps`, could replace `getDeri [![NPM](https://nodei.co/npm/react-memoize.png?downloads=true&stars=true)](https://nodei.co/npm/react-memoize/) -- [Memoize](#Memoize) - to create declarative memoized selection. -- [MemoizedFlow](#MemoizedFlow) - to create declarative memoized flow. -- [MemoizeContext](#MemoizeContext) - to create memoized selector from context(or any Consumer). -- [MemoizedRender](#MemoizedRender) - to create a render, memoized by a value provided. +- [Memoize](#memoize) - to create declarative memoized selection. +- [MemoizedFlow](#flow) - to create declarative memoized flow. +- [MemoizeContext](#memoizecontext) - to create memoized selector from context(or any Consumer). +- [MemoizedRender](#memoizedrender) - to create a render, memoized by a value provided. -Memoize, MemoizedFlow, MemoizeContext accepts one or more functions to select or transform -incoming data, and provide result to a function-as-child. +Memoize, MemoizedFlow, MemoizeContext accepts one or more functions to select or transform incoming data, and provide result to a function-as-child. MemoizedRender is memoizing the function-as-child itself. + ### Memoize ```js @@ -54,37 +54,6 @@ Memoize get `compute` function, add passes all the other props to it, streaming If `pure` prop is set ReactMemoize wil behave as PureComponent, and not update children when could not. -### MemoizeContext -React memoize also provides component to __select__ and __memoize__ data from React16 context, or any other component -which will pass some values into renderProp. - -```js -import {MemoizeContext} from 'react-memoize'; - - - - {values => } - - -``` -`consumer` could be any "context"-compatible Component - React.context, create-react-context, unstated, react-copy-write. -All the additional props will be passed down to consumer. - -It is better to explain using example. -```js - /> - -// will result - - -{ contextValues => ...} - -``` - -This is like Redux without dispatching. State in context, selector aka mapStateToProps, and magic memoization in between. - -__See it in action ->__ https://codesandbox.io/s/xjz5y3wzrz 🛠 - ## Flow `getDerivedStateFromProps` gives you ability to from a new state from props, while `componentDidUpdate` enables you to react to the state changes. @@ -133,6 +102,37 @@ own result over it. Until the last step will be reached, and output will be prov Each step is memoized, as usual, and will always reuse value from the steps before. +### MemoizeContext +React memoize also provides component to __select__ and __memoize__ data from React16 context, or any other component +which will pass some values into renderProp. + +```js +import {MemoizeContext} from 'react-memoize'; + + + + {values => } + + +``` +`consumer` could be any "context"-compatible Component - React.context, create-react-context, unstated, react-copy-write. +All the additional props will be passed down to consumer. + +It is better to explain using example. +```js + /> + +// will result + + +{ contextValues => ...} + +``` + +This is like Redux without dispatching. State in context, selector aka mapStateToProps, and magic memoization in between. + +__See it in action ->__ https://codesandbox.io/s/xjz5y3wzrz 🛠 + # MemoizedRender MemoizedRender is mostly usable with Context API ```js