Skip to content

Instantly share code, notes, and snippets.

@istarkov
Created September 3, 2017 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save istarkov/9b7d6dc28adc5c747ee5d2e562df19d3 to your computer and use it in GitHub Desktop.
Save istarkov/9b7d6dc28adc5c747ee5d2e562df19d3 to your computer and use it in GitHub Desktop.
/* @flow */
import React from 'react'
import { compose, defaultProps, withProps } from 'recompose'
import type { HOC } from 'recompose';
// type of Enhanced component props
type EnhancedComponentProps = {
text?: string,
};
const baseComponent = ({ text }) => <div>{text}</div>;
const enhance:HOC<*, EnhancedComponentProps> = compose(
defaultProps({
text: 'world',
}),
withProps(({ text }) => ({
text: `Hello ${text}`
}))
);
const EnhancedComponent = enhance(baseComponent);
export default EnhancedComponent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment