piral-debug-utils
Version:
Utilities for debugging Piral instances.
19 lines • 626 B
JavaScript
import { useState, useEffect } from 'react';
import { debugRouteCache } from './routeRefresh';
export function useDebugRouteFilter(paths) {
const [_, triggerChange] = useState(0);
useEffect(() => {
const handler = () => {
triggerChange(s => s + 1);
};
window.addEventListener('pilets-reloaded', handler);
return () => {
window.removeEventListener('pilets-reloaded', handler);
};
}, []);
if (!debugRouteCache.active) {
debugRouteCache.paths = paths;
}
return debugRouteCache.paths;
}
//# sourceMappingURL=useDebugRouteFilter.js.map