You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered an issue with the example code provided in the @bitnoi.se/react-scheduler README. It seems that there are missing imports and setup that result in errors when trying to run the example.
Steps to Reproduce:
Install the @bitnoi.se/react-scheduler library by running:
-npm install @bitnoi.se/react-scheduler dayjs
Copy the example code from the README into a React component:
`import { Scheduler, SchedulerData } from "@bitnoi.se/react-scheduler";
import dayjs from "dayjs";
default export function Component() {
const [filterButtonState, setFilterButtonState] = useState(0);
const [range, setRange] = useState({
startDate: new Date(),
endDate: new Date()
});
For some reason, when I create a separate TS project from scratch and use the example in readme.md, this issue arises. But it's working fine when I clone it from this Repository.
I encountered an issue with the example code provided in the @bitnoi.se/react-scheduler README. It seems that there are missing imports and setup that result in errors when trying to run the example.
Steps to Reproduce:
Install the @bitnoi.se/react-scheduler library by running:
-
npm install @bitnoi.se/react-scheduler dayjs
Copy the example code from the README into a React component:
`import { Scheduler, SchedulerData } from "@bitnoi.se/react-scheduler";
import dayjs from "dayjs";
default export function Component() {
const [filterButtonState, setFilterButtonState] = useState(0);
const [range, setRange] = useState({
startDate: new Date(),
endDate: new Date()
});
const handleRangeChange = useCallback((range) => {
setRange(range);
}, []);
const filteredMockedSchedulerData = mockedSchedulerData.map((person) => ({
...person,
data: person.data.filter(
(project) =>
dayjs(project.startDate).isBetween(range.startDate, range.endDate) ||
dayjs(project.endDate).isBetween(range.startDate, range.endDate) ||
(dayjs(project.startDate).isBefore(range.startDate, "day") &&
dayjs(project.endDate).isAfter(range.endDate, "day"))
)
}))
return (
<Scheduler
data={filteredMockedSchedulerData}
isLoading={isLoading}
onRangeChange={handleRangeChange}
onTileClick={(clickedResource) => console.log(clickedResource)}
onItemClick={(item) => console.log(item)}
onFilterData={() => setFilterButtonState(1)}
onClearFilterData={() => setFilterButtonState(0)}
config={{ zoom: 0, filterButtonState }}
/>
);
}
const mockedSchedulerData = [...] // Same as the example data in the README
`
Attempt to run the project, and you'll encounter the following errors:
-The isBetween function is not recognized.
To resolve this, you need to import and extend isBetween from dayjs:
import isBetween from "dayjs/plugin/isBetween"; dayjs.extend(isBetween);
The text was updated successfully, but these errors were encountered: