Skip to content

Instantly share code, notes, and snippets.

@bultas
Forked from iammerrick/children-as-function.js
Created November 20, 2017 15:44
Show Gist options
  • Save bultas/ccf657bec0d2ac36f13ff90bd8f3c001 to your computer and use it in GitHub Desktop.
Save bultas/ccf657bec0d2ac36f13ff90bd8f3c001 to your computer and use it in GitHub Desktop.
Which API do you prefer? Passing a function into the Ratio component or making a higher order component called Ratio you can use to configure a component.
<Ratio width={Ratio.OPTIONS.FLUID} x={3} y={4}>
{(width, height) => (
<Chart id={this.props.id} width={width} height={height} />
)}
</Ratio>
const ConfiguredChart = Ratio(Chart, {
x: 3,
y: 4,
width: Ratio.OPTIONS.FLUID
});
<ConfiguredChart id={this.props.id} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment