ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.
Python ai-agentsamdcomfyuidockerllama-cppllmlocal-ain8nnvidiaopen-webuiragself-hostedspeech-to-textstrix-halotext-to-speechworkflow-automation
import { useEffect } from 'react'
/** Request the browser's leave-page confirmation only while edits may be lost. */
export function useBeforeUnload(enabled) {
useEffect(() => {
if (!enabled) return
const protectDraft = (event) => {
event.preventDefault()
event.returnValue = true // Legacy browsers also require returnValue.
}
window.addEventListener('beforeunload', protectDraft)
return () => window.removeEventListener('beforeunload', protectDraft)
}, [enabled])
}