-
-
Save tdeekens/9d08b89191122e73ee90cae4e06312f5 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
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