{data.devices.payload.map(device => (
<div>
<Card className="card">
<CardContent>
<TextField
id="outlined-bare"
defaultValue={device.name}
margin="normal"
variant="outlined"
variables={{device.id}}
onChange={e => this.setState({ name: e.target.value })}
/>
<Typography>
Status: <span className={device.isOn === true ? "active" : "inActive"}>{device.isOn === true ? "WŁĄCZONY" : "WYŁĄCZONY"}</span>
</Typography>
</CardContent>
<CardActions>
<div className="wrapper">
<div className="buttonLeft">
<Mutation
mutation={device.isOn === true ? SETOFF_MUTATION : SETON_MUTATION}
variables={{ device.id }}>
{mutation => (
<div className="button">
<Button variant="contained" color={device.isOn === true ? "secondary" : "primary"} onClick={mutation}>
{device.isOn === true ? "WYŁĄCZ" : "WŁĄCZ"}
<PowerSettingsNewIcon className="rightIcon" />
</Button>
</div>
)}
</Mutation>
</div>
我只想将我的 device.id 从 map 函数传递到 Apollo Mutation。我可以使用其他值,例如 device.name。为什么我不能通过device.id?
相关分类