我已经添加了单选按钮组到mareferjs应用程序,这里的问题是当我尝试记录值时,我得到前一个单选按钮的值,而不是获取当前按钮的值。例如。假设当我点击从然后这个日志。我不知道是什么导致了这个问题。allawaitedall
我的代码
const [radioValue, setRadioValue] = React.useState("all");
function handleChangeRadio(event) {
const value = event.target.value;
setRadioValue(value);
console.log(radioValue); <---- Here When i try to log the value. it shows the value of previous button.
}
<RadioGroup
className={classes.radioGroup}
aria-label="status"
name="status"
value={radioValue}
onChange={handleChangeRadio}
row
>
<FormControlLabel
checked={radioValue === "all"}
value="all"
control={<Radio color="primary" />}
label="All"
labelPlacement="end"
className={classes.radioLabel}
/>
<FormControlLabel
checked={radioValue === "approved"}
value="approved"
control={<Radio color="primary" />}
label="Approved"
labelPlacement="end"
className={classes.radioLabel}
/>
<FormControlLabel
checked={radioValue === "awaited"}
value="awaited"
control={<Radio color="primary" />}
label="Awaited"
labelPlacement="end"
className={classes.radioLabel}
/>
<FormControlLabel
checked={radioValue === "on_hold"}
value="on_hold"
control={<Radio color="primary" />}
label="On Hold"
labelPlacement="end"
className={classes.radioLabel}
/>
</RadioGroup>
狐的传说
吃鸡游戏
相关分类