Skip to content

Instantly share code, notes, and snippets.

@yarigpopov
Last active October 11, 2021 11:27
Show Gist options
  • Save yarigpopov/36357882490f0be6001f6d17d82fdf73 to your computer and use it in GitHub Desktop.
Save yarigpopov/36357882490f0be6001f6d17d82fdf73 to your computer and use it in GitHub Desktop.
RadioImageForm.render() и RadioImageForm.RadioInput
export class RadioImageForm extends React.Component<Probs, State> {
// ...
render(): React.ReactElement {
const { currentValue, onChange, defaultValue } = this.state;
return (
<RadioImageFormWrapper>
<form>
{
React.Children.map(this.props.children,
(child: React.ReactElement) =>
React.cloneElement(child, {
currentValue,
onChange,
defaultValue,
}),
)
}
</form>
</RadioImageFormWrapper>
)
}
// ...
}
export class RadioImageForm extends React.Component<Probs, State> {
// ...
render(): React.ReactElement {
const { currentValue, onChange, defaultValue } = this.state;
return (
<RadioImageFormWrapper>
<form>
{
React.Children.map(this.props.children,
(child: React.ReactElement) =>
React.cloneElement(child, {
currentValue,
onChange,
defaultValue,
}),
)
}
</form>
</RadioImageFormWrapper>
)
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment