Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // @flow
- import * as React from "react";
- import { compose, defaultProps, withProps, type HOC } from "recompose";
- type EnhancedComponentProps = {
- text?: string
- };
- type BaseCompProps = {
- text: string,
- age?: number
- };
- const baseComponent = ({ text }: BaseCompProps) => <div>{text}</div>;
- const enhance: HOC<*, EnhancedComponentProps> = compose(
- defaultProps({
- text: "world"
- }),
- withProps(({ text }) => ({
- text: `Hello ${text}`
- }))
- );
- const EnhancedComponent = enhance(baseComponent);
- export default EnhancedComponent;
Add Comment
Please, Sign In to add comment