cleaned up styling for editor
This commit is contained in:
1 parent
bfc95db6f6
commit
4cfc429980
25 files changed
+532
-230
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { useRef, useEffect } from 'react';
|
||||
|
||||
|
||||
export const useDelayEffect = (cb: () => void, deps: any[], timeout: number) => {
|
||||
const fcn = useDelayedFunction(cb, timeout);
|
||||
useEffect(() => {
|
||||
fcn()
|
||||
}, [deps])
|
||||
}
|
||||
|
||||
export const useDelayedFunction = <FcnParams extends any[]>(
|
||||
cb: (...p: FcnParams) => void, timeout: number
|
||||
) => {
|
||||
const timeid = useRef<number | null>(null);
|
||||
return (...args: FcnParams) => {
|
||||
if (timeid.current) {
|
||||
window.clearTimeout(timeid.current)
|
||||
}
|
||||
timeid.current = window.setTimeout(() => {
|
||||
cb(...args)
|
||||
}, timeout)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user