mirror of
https://github.com/Stef-00012/Zipline-Android-App.git
synced 2025-05-10 18:05:52 +02:00
26 lines
714 B
TypeScript
26 lines
714 B
TypeScript
import { useShareIntentContext } from "expo-share-intent";
|
|
import { useEffect, useState } from "react";
|
|
import { useRouter } from "expo-router";
|
|
|
|
export const useShareIntent = (skipRedirect = false) => {
|
|
const router = useRouter();
|
|
const { hasShareIntent, resetShareIntent } = useShareIntentContext();
|
|
const [isMounted, setIsMounted] = useState<boolean>(false)
|
|
|
|
useEffect(() => {
|
|
setIsMounted(true);
|
|
}, []);
|
|
|
|
if (skipRedirect) return resetShareIntent;
|
|
|
|
// biome-ignore lint/correctness/useExhaustiveDependencies: .
|
|
useEffect(() => {
|
|
if (isMounted && hasShareIntent) {
|
|
router.replace({
|
|
pathname: "/shareintent",
|
|
});
|
|
}
|
|
}, [hasShareIntent, isMounted]);
|
|
|
|
return resetShareIntent;
|
|
};
|