Created
May 24, 2016 23:41
-
-
Save iammerrick/2d7b0398eae175d14687745bf95eda72 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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Ratio width={Ratio.OPTIONS.FLUID} x={3} y={4}> | |
{(width, height) => ( | |
<Chart id={this.props.id} width={width} height={height} /> | |
)} | |
</Ratio> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
I'm a little confused by this example so I'm going to try to port it to Elm.
are we creating a new
Ratio
component that we want to pass a configured chart?I'm not sure if this is a great translation. I'm not sure I ever ran into this problem in Elm.
What problem is this trying to solve?