i'm a newbie for react and have a simple question regarding it. would be really helpful if you answer the question, thank you!!????
As you know, RadioGroup has the prop called "value", and the official says you can control the radio with it and "onChange" props.
ref) https://mui.com/components/radio-buttons/
<FormControl>
<FormLabel id="demo-controlled-radio-buttons-group">Gender</FormLabel>
<RadioGroup
aria-labelledby="demo-controlled-radio-buttons-group"
name="controlled-radio-buttons-group"
value={value}
onChange={handleChange}
>
<FormControlLabel value="female" control={<Radio />} label="Female" />
<FormControlLabel value="male" control={<Radio />} label="Male" />
</RadioGroup>
</FormControl>
Here, i have one question, "why i need the prop, 'value', in RadioGroup?".
Actually, the prop "onChange" can receive the value from the selected button by accessing "event.target.value". the below is from the source code of MUI RadioGroupProps.
/**
* Callback fired when a radio button is selected.
*
* @param {object} event The event source of the callback.
* You can pull out the new value by accessing `event.target.value` (string).
*/
onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: string) => void;
the question might be non-sense for knowledgeable people, but would appreciate if you answer it????