如何将道具传递给 reactjs材质对话框?如果我这样做< FormDialog value={this.prop.value} />
,抛出Type '{ value: any; }' is not assignable to type 'IntrinsicAttributes'
错误。我如何分配类型FormDialog()
或任何其他方式将道具传递给该组件?
模态的.tsx
export default function FormDialog() {
const [open, setOpen] = React.useState(false);
function handleClickOpen() {
setOpen(true);
}
function handleClose() {
setOpen(false);
}
return (
<div>
<Button variant="outlined" color="primary" onClick={handleClickOpen}>
Open form dialog
</Button>
<Dialog
open={open}
onClose={handleClose}
aria-labelledby="form-dialog-title"
>
<DialogTitle id="form-dialog-title">Subscribe</DialogTitle>
<DialogContent>
<TextField
autoFocus
margin="dense"
id="name"
label="Email Address"
type="email"
fullWidth
/>
</DialogContent>
<DialogActions>
<Button onClick={handleClose} color="primary">
Subscribe
</Button>
</DialogActions>
</Dialog>
</div>
);
}
卡片.tsx
class ShipmentCard extends Component<ShipmentCardProps, ShipmentCardState> {
render() {
return (
<Card className="Card">
<CardContent className="Card-Content">
<FormDialog />
<Grid container spacing={3}>
<h3 className="Card-Content__Title">{this.props.value.name}</h3>
<FormDialog />{/*how i can pass this.props.value */}
</Grid>
</CardContent>
</Card>
);
}
}