Guest User

Untitled

a guest
Sep 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. // @flow
  2. import * as React from "react";
  3. import { compose, defaultProps, withProps, type HOC } from "recompose";
  4. type EnhancedComponentProps = {
  5. text?: string
  6. };
  7. type BaseCompProps = {
  8. text: string,
  9. age?: number
  10. };
  11. const baseComponent = ({ text }: BaseCompProps) => <div>{text}</div>;
  12. const enhance: HOC<*, EnhancedComponentProps> = compose(
  13. defaultProps({
  14. text: "world"
  15. }),
  16. withProps(({ text }) => ({
  17. text: `Hello ${text}`
  18. }))
  19. );
  20. const EnhancedComponent = enhance(baseComponent);
  21. export default EnhancedComponent;
Add Comment
Please, Sign In to add comment