Guest User

Untitled

a guest
Feb 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. export const createContext = value => {
  2. const context = reactCreateContext(value);
  3.  
  4. export const withContext = Component => {
  5. const C = props => (
  6. <context.Consumer>
  7. {context => <Component {...context} {...props} />}
  8. </context.Consumer>
  9. );
  10.  
  11. C.displayName = `withContext(${Component.displayName || Component.name})`;
  12.  
  13. return C;
  14. };
  15.  
  16. return {
  17. Provider: context.Provider,
  18. Consumer: context.Consumer,
  19. withContext,
  20. };
  21. };
Add Comment
Please, Sign In to add comment