Open levis-creator opened 3 months ago
Hi @levis-creator I faced the issue also. This code works well for me. Do check it out
`"use client"; import { useState } from 'react'; import { Calendar, dateFnsLocalizer } from 'react-big-calendar'; import { format, parse, startOfWeek, getDay } from 'date-fns'; import "react-big-calendar/lib/css/react-big-calendar.css";
const locales = { 'en-US': require('date-fns/locale/en-US'), };
const localizer = dateFnsLocalizer({ format, parse, startOfWeek, getDay, locales, });
const events = [ { title: 'Lorem', start: new Date(2023, 6, 21, 9, 0), end: new Date(2023, 6, 21, 11, 0), resourceId: 1, status: 'Check In', }, { title: 'Ipsum', start: new Date(2023, 6, 21, 10, 0), end: new Date(2023, 6, 21, 10, 10), resourceId: 1, status: 'Completed', }, // Add more events here ];
function DashboardCalendar({ className }) { const [view, setView] = useState('week'); const [date, setDate] = useState(new Date());
const handleNavigate = (newDate) => { setDate(newDate); };
const handleViewChange = (newView) => { setView(newView); };
return (
<div className={${className}
} style={{ height: '500px' }}>
<Calendar
localizer={localizer}
events={events}
startAccessor="start"
endAccessor="end"
view={view}
date={date}
onNavigate={handleNavigate}
onView={handleViewChange}
/>
export default DashboardCalendar;`
same issue. +1
Hi @levis-creator I faced the issue also. This code works well for me. Do check it out
`"use client"; import { useState } from 'react'; import { Calendar, dateFnsLocalizer } from 'react-big-calendar'; import { format, parse, startOfWeek, getDay } from 'date-fns'; import "react-big-calendar/lib/css/react-big-calendar.css";
const locales = { 'en-US': require('date-fns/locale/en-US'), };
const localizer = dateFnsLocalizer({ format, parse, startOfWeek, getDay, locales, });
const events = [ { title: 'Lorem', start: new Date(2023, 6, 21, 9, 0), end: new Date(2023, 6, 21, 11, 0), resourceId: 1, status: 'Check In', }, { title: 'Ipsum', start: new Date(2023, 6, 21, 10, 0), end: new Date(2023, 6, 21, 10, 10), resourceId: 1, status: 'Completed', }, // Add more events here ];
function DashboardCalendar({ className }) { const [view, setView] = useState('week'); const [date, setDate] = useState(new Date());
const handleNavigate = (newDate) => { setDate(newDate); };
const handleViewChange = (newView) => { setView(newView); };
return ( <div className={
${className}
} style={{ height: '500px' }}> ); }export default DashboardCalendar;`
Thank you very much this is very helpful
Hi @levis-creator I faced the issue also. This code works well for me. Do check it out
@Shanmugavadivelu7 this just results in a blank page. The DashboardCalendar isn't even being used. How did this work well for you? Do you have a full working example?
@levis-creator is this still a issue, if not please close the issue
@hak33m16 create a new page in next js. Copy paste the code and navigate to your route in browser.
One can make it work by providing date, view, onNavigate and onView explicitly:
const [view, setView] = useState<View>(Views.MONTH)
const [date, setDate] = useState<Date>(new Date())
return (
<Calendar
// ...
view={view}
onView={setView}
date={date}
onNavigate={setDate}
/>
)
(the code snippet can be used freely)
Check that this is really a bug
Reproduction link
https://github.com/jquense/react-big-calendar/blob/master/stories/demos/exampleCode/basic.js
Bug description
I have added react-big-calender library inside my app it is displaying the calendar but i cannot navigate to the different options, I have mirrored one of the the documentation example but still having the same issue
Expected Behavior
Expected to be able to navigate within the tabs option
Actual Behavior
Unable to navigate within the tabs
react-big-calendar version
1.13.1
React version
18
Platform/Target and Browser Versions
All
Validations
Would you like to open a PR for this bug?