使用地图功能时单选按钮 select 问题

Radio button select issue, while using Map function

我有一个数组列表,我正在使用地图函数渲染它。每个对象都有一个单选按钮。现在,当我单击数据的单选按钮时,它显示 "TypeError: Cannot read property 'value' of undefined"。我不明白,我做错了什么。请检查下面我的代码。

从 'react' 导入 React,{ 组件} 从'@material-ui/core';

导入{withStyles, Typography, Grid, Radio}
class EventSupervisor extends Component {
    constructor(props){
        super(props); 
        this.state = {
            lists: [
                {id: 1, proImg: require("../../../../../assets/images/man-avatar.jpg"), imgAlt: 'Profile Image', name: 'Sam', role: 'Teacher'},
                {id: 2, proImg: require("../../../../../assets/images/man-avatar.jpg"), imgAlt: 'Profile Image', name: 'Sam', role: 'Teacher'},
                {id: 3, proImg: require("../../../../../assets/images/man-avatar.jpg"), imgAlt: 'Profile Image', name: 'Sam', role: 'Teacher'}
            ],
            selectedValue: 1
        }
    }

    handleChange=(e)=>{
        this.setState({
            selectedValue: e.target.value
        })
    }
    render() {
        const { classes } = this.props
        return (
            <div className= {classes.supervisorWrapper}>

                <Grid container>
                    <Grid item xs='6'>
                        <Typography className={classes.selectContent}>Select Supervisor</Typography>
                        {/* <SupervisorList lists={this.state.lists} selectedValue={this.state.selectedValue} onChange={this.handleChange}/> */}
                        {
                this.state.lists.map((list)=> { 
                    return (
                        <div className={classes.superWrapper} key={list.id}>
                            <img src={list.proImg} alt={list.imgAlt} />
                            <Typography className={classes.supervisorName}>{list.name}<span className={classes.supervisorRole}>{list.role}</span></Typography>
                            <Radio 
                                checked = {this.state.selectedValue === list.id}
                                onChange = {()=>this.handleChange(list.id)}
                                value = {this.state.selectedValue}
                                classes={{
                                    root: classes.radioRoot,
                                    checked: classes.rootChecked
                                }}
                            />
                        </div>    
                    )   
                })
            }
                    </Grid>
                    <Grid item xs='6'>

                    </Grid>
                </Grid>
            </div>
        )
    }
}

export default withStyles(styles)(EventSupervisor)
<Radio
    ...
    onChange = {(e)=>this.handleChange(e)}
or
    onChange = {this.handleChange}
    ...
/>

e.target 存在于点击事件中。

处理更改的函数预期事件:handleChange(e) --> selectedValue: e.target.value,但在您的 onChange 道具中,您传递的是 ID:onChange = {()=>this.handleChange(list.id)}

只需更改 handleChange 函数以将 id 作为参数并使用它来设置状态:handleChange(id) ---> selectedValue: id

handleChange=(id)=>{
    this.setState({
        selectedValue: id
    })
}