我遇到此错误:无法在我的代码中的未安装组件上找到节点。
这是我的一组代码:
class CalendarScheduler extends Component {
state = {
viewModel: schedulerData,
showBookingDialog: false
}
handleClickOpen = () => {
// this.setState({ showBookingDialog: true });
this.setState((prevState) => {
return { showBookingDialog: !prevState.showBookingDialog };
})
};
handleClose = () => {
this.setState({ showBookingDialog: false });
};
render() {
const { viewModel } = this.state;
let schedulerData = this.state.viewModel;
schedulerData.setResources(this.props.rooms);
return (
<div>
<Scheduler schedulerData={viewModel}
prevClick={this.prevClick}
nextClick={this.nextClick}
onSelectDate={this.onSelectDate}
newEvent={this.newEvent}
/>
{this.state.showBookingDialog === true && (
<BookingDialog
open={this.state.showBookingDialog}
onClose={this.handleClose} />
)}
</div>
);
}
这是我的功能:
newEvent = (schedulerData, slotId, slotName, start, end, type, item) => {
this.setState({
showBookingDialog: true
});
我的错误消息指向newEvent中的this.setState。