Skip to content

Instantly share code, notes, and snippets.

@alexkrolick
Last active September 20, 2017 00:26
Show Gist options
  • Save alexkrolick/e38eec70130390b23bf54baaa78368bb to your computer and use it in GitHub Desktop.
Save alexkrolick/e38eec70130390b23bf54baaa78368bb to your computer and use it in GitHub Desktop.
// JSX
const withFooProp = WrappedComponent => props => <WrappedComponent foo={2} {...props} />
// createElement
const withFooProp = WrappedComponent => props => h(WrappedComponent, { foo: 2, ...props })
const Bar // ... a component
export default withFooProp(Bar) // export an augmented version of Bar
// elsewhere...
import Bar from './bar'
// props {baz: 2, foo: 2}
<Bar baz={2} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment