12345678910111213141516171819202122 |
- import React from "react";
-
- const CommentContext = React.createContext();
-
- // This function takes a component...
- export function Comment(Component) {
- // ...and returns another component...
- return function(props) {
- // ... and renders the wrapped component with the context theme!
- // Notice that we pass through any additional props as well
- return (
- <CommentContext.Consumer>
- {app => <Component {...props} app={app} />}
- </CommentContext.Consumer>
- );
- };
- }
-
- export { CommentContext };
-
- export default Comment;
|