Skip to content

Instantly share code, notes, and snippets.

@tdeekens
Created December 16, 2017 14:02
Show Gist options
  • Save tdeekens/def88616c4995569c45f55aecb64c511 to your computer and use it in GitHub Desktop.
Save tdeekens/def88616c4995569c45f55aecb64c511 to your computer and use it in GitHub Desktop.
const RadioGroup = props =>
React.Children.map(props.children, child => {
if (child.type === RadioOption)
return React.cloneElement(child, {
isChecked: props.value === child.props.value,
name: props.name,
onChange: props.handleChange
});
return child;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment