如何解决:无法在未安装的组件上找到节点

时间:2018-10-29 00:43:38

标签: reactjs scheduler

我遇到此错误:无法在我的代码中的未安装组件上找到节点。

这是我的一组代码:

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。

0 个答案:

没有答案