@router-cli/react-router
Version:
File based routing cli for react-router-dom. Types and components. see @router-cli/react-router-dev for the cli and plugins.
15 lines (13 loc) • 348 B
text/typescript
import { useRef } from 'react';
export const useGuards = (guard?: () => {}): boolean => {
const hasRunRef = useRef(false);
if (guard && hasRunRef.current === false) {
hasRunRef.current = true;
guard();
}
return true;
}
export const guardLoader = (guard: () => {}) => {
guard();
return null;
}