Last active
November 1, 2018 03:21
-
-
Save jossmac/4b9dc6e2cd50cb718e9a9d96bc016f7f to your computer and use it in GitHub Desktop.
Pseudo code for a consumer component
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
import React from 'react'; | |
import { ToastContext } from './Provider'; | |
export const ToastConsumer = ({ children }) => ( | |
<ToastContext.Consumer> | |
{context => children(context)} | |
</ToastContext.Consumer> | |
); | |
// Higher-Order Component | |
export const withToastManager = (Comp) => (props) => ( | |
<ToastConsumer> | |
{context => <Comp toastManager={context} {...props} />} | |
</ToastConsumer> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment