mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-29 00:20:04 +01:00
22 lines
524 B
TypeScript
22 lines
524 B
TypeScript
import { useEffect, useState } from "react";
|
|
import { InteractionManager } from "react-native";
|
|
|
|
export const useDelayLayout = (delay: number) => {
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
let cancel: () => void;
|
|
const timeout = setTimeout(() => {
|
|
cancel = InteractionManager.runAfterInteractions(() => {
|
|
setLoading(false);
|
|
}).cancel;
|
|
}, delay);
|
|
return () => {
|
|
cancel && cancel();
|
|
clearTimeout(timeout);
|
|
};
|
|
}, [delay]);
|
|
|
|
return loading;
|
|
};
|