我正在使用软件包@fullcalendar/react
在我的管理仪表板网站中创建日历.我想要的是允许管理员添加事件,它们将显示在firebase firestore数据库的完整日历中.
但是,当我获取我的事件集合时,它只是在日历中不显示任何内容.
我做错了什么?为什么这些事件没有出现?
这是我的eventsData数组的控制台日志(log).
这是我的代码:
import FullCalendar from "@fullcalendar/react";
import dayGridPlugin from "@fullcalendar/daygrid";
import interactionPlugin, { Draggable } from "@fullcalendar/interaction";
import BootstrapTheme from "@fullcalendar/bootstrap";
import firebase from '../../firebase';
const Calender = props => {
const [eventsData, setEventsData] = useState({})
const getEventsData = async () => {
await firebase.firestore().collection("Events").get().then((snapshot) => {
const events = snapshot.docs.map(event => event.data());
setEventsData(events)
console.log(events)
}).catch((e) => {
console.log(e + "fetching error")
})
}
useEffect(() => {
getEventsData()
},[])
return(
<FullCalendar
plugins={[
BootstrapTheme,
dayGridPlugin,
interactionPlugin,
]}
slotDuration={"00:15:00"}
handleWindowResize={true}
themeSystem="bootstrap"
headerToolbar={{
left: "prev,next today",
center: "title",
right: "dayGridMonth,dayGridWeek,dayGridDay",
}}
events={eventsData}
editable={true}
droppable={true}
selectable={true}
/>
)
}