Skip to content

Commit

Permalink
move constantDiv to hook for improved compatibility with Next.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jvllmr committed Jul 26, 2024
1 parent df14197 commit 40436c5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/controller/selectControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ export type SchedulerMomentOnDragEndFn<TResource> = (
resource: TResource,
) => void;

const constantDiv = document.createElement("div");

export const useSchedulerSelect = <TData, TResource>(
onSelect?: OnSelectFn<TData, TResource>,
) => {
const constantDiv = useMemo(() => document.createElement("div"), []);
const [firstMoment, setFirstMoment] = useState<Dayjs | null>(null);
const [lastMoment, setLastMoment] = useState<Dayjs | null>(null);

Expand Down Expand Up @@ -54,7 +53,7 @@ export const useSchedulerSelect = <TData, TResource>(
}
}
: undefined,
[firstMoment, lastMoment, onSelect],
[constantDiv, firstMoment, lastMoment, onSelect],
);

const onDragEnd: SchedulerMomentOnDragEndFn<TResource> | undefined = useMemo(
Expand Down

0 comments on commit 40436c5

Please sign in to comment.