Skip to content

Instantly share code, notes, and snippets.

@tdeekens
Last active April 28, 2018 13:46
Show Gist options
  • Save tdeekens/8805dc1bda9e4f11a99f582ae197f0e5 to your computer and use it in GitHub Desktop.
Save tdeekens/8805dc1bda9e4f11a99f582ae197f0e5 to your computer and use it in GitHub Desktop.
class RadioGroup extends React.Component {
render() {
return this.props.children({
name: this.props.name,
onChange: this.handleChange
});
}
}
class UIComponent extends React.Component {
handleChange = event => {};
render() {
return (
<RadioGroup
name="size"
value={this.props.tshirt.value}
onChange={this.handleChange}
>
{({ name, onChange }) => (
<React.Fragment>
<RadioOption value="m" name={name} onChange={onChange}>
M
</RadioOption>
{/* two more of these with the respective props */}
</React.Fragment>
)}
</RadioGroup>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment