Question: How to pass / create and pass unique key to Radio Button , also i have a Table component that takes data(arra) and it also says that [antd: Table]
Each record in dataSource of table should have a unique key
prop, or set rowKey
. Thank you in advance.
const userRoles = [
{
key: "ROLE_ADMIN",
name: "Admin"
},
{
key: "ROLE_USER",
name: "User",
}
];
class RoleUpdate extends PureComponent {
constructor(props) {
super(props);
this.state = {
userRole: props.role,
}
}
handleChange = (event) => {
this.setState({
userRole: {
role: event.target.value
}
});
this.props.onRoleChange(event.target.value);
};
render() {
return (
<Radio.Group value={this.state.userRole.role} onChange={this.handleChange}>
{userRoles.map(role => {
return <Radio.Button value={role.key}>{role.name}</Radio.Button>
})}
</Radio.Group>
)
};
}
export default RoleUpdate;
<Table size={"middle"}
columns={columns}
dataSource={this.state.results}
/>