Skip to content

Instantly share code, notes, and snippets.

@tdeekens
Last active December 16, 2017 17:23
Show Gist options
  • Save tdeekens/9d08b89191122e73ee90cae4e06312f5 to your computer and use it in GitHub Desktop.
Save tdeekens/9d08b89191122e73ee90cae4e06312f5 to your computer and use it in GitHub Desktop.
const radioChildContextTypes = {
radioGroup: PropTypes.shape({
onChange: PropTypes.function,
value: PropTypes.string,
name: PropTypes.string
})
};
const getChildContext = props => ({
radioGroup: {
onChange: props.onChange,
value: props.value,
name: props.name
}
})
export class RadioGroup extends React.Component { /* ... */}
export default withContext(radioChildContextTypes, getChildContext)(RadioGroup);
export class RadioOption extends React.Component { /* ... */}
export default getContext(getChildContext)(RadioOption);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment