In the
RadioGroup
component, when cloning eachchild
element (RadioOption
), what’s the condition that determines the value of the newchecked
prop that gets merged into the existing props of eachRadioOption
component? Recall that theRadioGroup
component has three props -onChange
,selected
andchildren
- and that eachRadioOption
component receives two props -value
andchildren
.React.cloneElement(child, { onChange, checked: child.props.value === selected, });
React.cloneElement(child, { onChange, checked: child.checked === true, });
React.cloneElement(child, { onChange, checked: child.props.selected, });
Inside the
RadioOption
component, what should be the value of theonChange
prop from theradio
input element? Recall that theRadioOption
component receives four props -value, checked, onChange
andchildren
.<input type="radio" onChange={e => onChange(e.target.value)} />
<input type="radio" onChange={props.onChange} />
<input type="radio" onChange={props.onChange} />
What are the arguments that the
React.Children.map
function receives?The first argument is the children prop, and there is no second argument.
The first argument is the children prop, and the second argument is a transformation function that returns a new React element.
The first argument is the children prop, and the second argument is a predicate function that returns a boolean.