呈现 Big React Calendar 时出现控制台错误

Console error when rendering Big React Calendar

我在呈现 BigCalendar 组件时不断收到此控制台错误消息。

我该如何解决这个问题?

"Uncaught Error: NoopWrapper.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object. at invariant (invariant.js?994a:42) at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js?8c6a:828) at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js?8c6a:359) at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js?8c6a:255) at Object.mountComponent (ReactReconciler.js?af94:43) at ReactDOMComponent.mountChildren (ReactMultiChild.js?0c7d:234) at ReactDOMComponent._createInitialChildren (ReactDOMComponent.js?9b5f:701) at ReactDOMComponent.mountComponent (ReactDOMComponent.js?9b5f:520) at Object.mountComponent (ReactReconciler.js?af94:43) at Object.updateChildren (ReactChildReconciler.js?f170:119)"

这是我的代码:

import React from 'react';
import BigCalendar from 'react-big-calendar';
import moment from 'moment';
import 'react-big-calendar/lib/css/react-big-calendar.css';

const localizer = BigCalendar.momentLocalizer(moment);

const MyCalendar = () => {
    const dummyEvents = [
        {
            allDay: true,
            end: new Date('October 10, 2018 11:13:00'),
            start: new Date('October 09, 2018 11:13:00'),
            title: 'hi'
        }
    ];
    return (
        <div style={{ height: '60rem' }}>
            <BigCalendar
                events={dummyEvents}
                startAccessor="start"
                endAccessor="end"
                localizer={localizer}
            />
        </div>
    );
};

export default MyCalendar;

如果您可以指定您正在使用的 react-big-calendar 版本,将会很有用。

无论如何,我不确定是什么导致了这个问题,但我在使用 react-big-calendar 的版本 0.20.1 时也收到了这个错误。临时修复可能是降级并使用例如版本 0.19.2

如果有帮助请告诉我。