Submit
Path:
~
/
/
usr
/
share
/
grafana
/
public
/
app
/
core
/
hooks
/
File Content:
useCleanup.ts
import { useEffect, useRef } from 'react'; import { useDispatch } from 'app/types'; import { cleanUpAction, CleanUpAction } from '../actions/cleanUp'; export function useCleanup(cleanupAction: CleanUpAction) { const dispatch = useDispatch(); //bit of a hack to unburden user from having to wrap stateSelcetor in a useCallback. Otherwise cleanup would happen on every render const selectorRef = useRef(cleanupAction); selectorRef.current = cleanupAction; useEffect(() => { return () => { dispatch(cleanUpAction({ cleanupAction: selectorRef.current })); }; }, [dispatch]); }
Edit
Rename
Chmod
Delete
FILE
FOLDER
INFO
Name
Size
Permission
Action
useBusEvent.ts
599 bytes
0644
useCleanup.ts
602 bytes
0644
useMediaQueryChange.ts
519 bytes
0644
useNavModel.ts
291 bytes
0644
useQueryParams.ts
592 bytes
0644
N4ST4R_ID | Naxtarrr