Buckets:
| import { useEffect, useRef } from 'react'; | |
| export function useFromNull(effect: () => void | (() => void), deps: Array<any | null | undefined>) { | |
| const prevDepsRef = useRef<(any | null | undefined)[]>([]); | |
| useEffect(() => { | |
| const shouldRun = deps.some((dep, i) => prevDepsRef.current[i] == null && dep != null); | |
| if (shouldRun) { | |
| const cleanup = effect(); | |
| prevDepsRef.current = deps; | |
| return cleanup; | |
| } | |
| prevDepsRef.current = deps; | |
| }, deps); | |
| } | |
Xet Storage Details
- Size:
- 484 Bytes
- Xet hash:
- 270a40f3ea7c2f1548c85ab1839f6457c652f80eba3bffb4d3e2a8117f81d0a1
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.