通用评论

12345678910111213141516171819202122
  1. import React from "react";
  2. const CommentContext = React.createContext();
  3. // This function takes a component...
  4. export function Comment(Component) {
  5. // ...and returns another component...
  6. return function(props) {
  7. // ... and renders the wrapped component with the context theme!
  8. // Notice that we pass through any additional props as well
  9. return (
  10. <CommentContext.Consumer>
  11. {app => <Component {...props} app={app} />}
  12. </CommentContext.Consumer>
  13. );
  14. };
  15. }
  16. export { CommentContext };
  17. export default Comment;