This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Router } from "next/router"; | |
import { useCallback, useEffect } from "react"; | |
export const useBeforeUnload = ( | |
enabled: boolean | (() => boolean) = true, | |
message = "Changes you made may not be saved.", | |
) => { | |
const handler = useCallback( | |
(event: BeforeUnloadEvent) => { | |
const finalEnabled = typeof enabled === "function" ? enabled() : true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
schema.plugin(paginate); | |
export const CourseModel: PaginateModel<ICourse> = | |
(models.Course as PaginateModel<ICourse>) || | |
model<ICourse, PaginateModel<ICourse>>("Course", schema); |