Open cback97 opened 4 days ago
cannot reproduce with the example.
I think you should have something like this in your 404 page, the example uses the Home
in [...unmatched]
and then redirect :
useEffect(() => {
if (hasShareIntent) {
// we want to handle share intent event in a specific page
router.replace({
pathname: "shareintent",
});
}
}, [hasShareIntent]);
here is my implementation! :) @achorein
app/_layout.tsx
return (
<ShareIntentProvider
options={{
resetOnBackground: true,
// debug: true,
onResetShareIntent: () => router.replace("/"),
}}
>
<GestureHandlerRootView style={{ flex: 1 }}>
<ToastProvider>
<SelectedProductProvider>
<Stack
screenOptions={{
headerShown: false,
contentStyle: { backgroundColor: BrandNeutrals.white },
}}
initialRouteName="index"
>
<Stack.Screen name="index" />
</Stack>
</SelectedProductProvider>
</ToastProvider>
</GestureHandlerRootView>
</ShareIntentProvider>
);
index.tsx will then route me to home.tsx where I am using the following
useEffect(() => {
async function runEffect(fileUri: string) {
try {
const base64 = await FileSystem.readAsStringAsync(fileUri, {
encoding: FileSystem.EncodingType.Base64,
});
setImage(base64);
} catch (error) {
console.error("Error converting file to base64", error);
}
}
if (!hasShareIntent || !shareIntent.files) return;
const filePath = shareIntent.files[0].path;
runEffect(filePath);
}, [hasShareIntent, resetShareIntent, shareIntent]);
Everything else works as it should, but the navigation always routes me to +not-found.tsx.
For reference, here is my index file
import { Redirect } from "expo-router";
import React, { useEffect, useState } from "react";
import checkFirstLaunch from "./util/checkFirstLaunch";
const SetInitialRoute = () => {
const [sIsFirstLaunch, _setIsFirstLaunch] = useState<boolean | null>(null);
useEffect(() => {
const aDetermineFirstLaunch = async () => {
try {
const aFirstLaunch = await checkFirstLaunch();
_setIsFirstLaunch(aFirstLaunch);
} catch (error) {
console.error(error);
// Assume it's not the first launch if there's an error
_setIsFirstLaunch(false);
}
};
void aDetermineFirstLaunch();
}, []);
/**
* This if statement handles the loading state
* we want sIsFirstLaunch to be null while we're determining the status
* sIsFirstLaunch will be true every time after the first launch
*/
if (sIsFirstLaunch === null) {
return null;
}
return sIsFirstLaunch ? (
<Redirect href={"/splash"} />
) : (
<Redirect href={"/home"} />
);
};
export default SetInitialRoute;
cannot reproduce with the example.
I think you should have something like this in your 404 page, the example uses the
Home
in[...unmatched]
and then redirect :useEffect(() => { if (hasShareIntent) { // we want to handle share intent event in a specific page router.replace({ pathname: "shareintent", }); } }, [hasShareIntent]);
In attempt to doing this, we are still brought to the not found screen briefly which is not a solution. I'm just curious where the package is trying to bring me on launch or on navigating to the foreground.
When sharing an image with my application, the route handling by default takes me to +not-found.tsx in my expo-router application
Share image to my expo-router application is the step to reproduce
Environment