-
-
Save tdeekens/6e28f85e442de713cd785f7da5aedbc0 to your computer and use it in GitHub Desktop.
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
class RadioGroup extends React.Component { | |
getOptionProps = () => ({ | |
name: this.props.name, | |
value: this.props.value, | |
onChange: this.handleChange | |
}); | |
render() { | |
return this.props.children({ | |
getOptionProps: this.getOptionProps | |
}); | |
} | |
} | |
class UIComponent extends React.Component { | |
handleChange = event => {}; | |
render() { | |
return ( | |
<RadioGroup | |
name="size" | |
value={this.props.tshirt.value} | |
onChange={this.handleChange} | |
> | |
{({ getOptionProps }) => ( | |
<React.Fragment> | |
<RadioOption {...getOptionProps()} value="m"> | |
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