Skip to content

Instantly share code, notes, and snippets.

View buYoung's full-sized avatar

BuYoungLee buYoung

  • Korean
View GitHub Profile
@buYoung
buYoung / howToUse.tsx
Last active February 2, 2024 04:38
Custom Hook for React Router v6 Before the Addition of useBlocker
// use case useStateWithCallbackLazy for blocking Status
function Ui(props) {
const [promptStatus, setPromptStatus] = useStateWithCallbackLazy(true);
const [showPrompt, confirmNavigation, cancelNavigation] = useCallbackPrompt(promptStatus);
const handleExit = () => {
confirmNavigation();
setPromptStatus(false, () => {
navigate(pageUrl });
});