nandorojo / expo-next-react-navigation

⛴ Make Next.js and react-navigation play nicely together with an Expo/React Native Web app.
408 stars 32 forks source link

how can get Link params after refresh page? #46

Closed mojtabahub closed 3 years ago

mojtabahub commented 3 years ago

Hello,

I can send Link params successfully but when i refresh page on browser, i can't get params and i get "Tried to get param page but it does not exist" error on console

how can get params after refresh page?

thanks

nandorojo commented 3 years ago

This might be due to next routing not including the params on the first render. Please try importing router = useRouter() from next/router, and try to log router.query to see what you get.

mojtabahub commented 3 years ago

Thank you so much, it solved

I have another question how can get current routeName, when i navigate to page i want get current routeName, I need it for anroid app, how can get that?

thanks

nandorojo commented 3 years ago

If you want it on web, it's .pathname. This isn't an option on native, you should use dangerouslyGetNavigationState.

mojtabahub commented 3 years ago

Thank you @nandorojo

mojtabahub commented 3 years ago

Hello,

I use Link like this: <Link web={{ as: "/sell/SM-S-589251/", path: "/sell" }} routeName="sell" >Sell

when i click on Sell i will navigate to sell page successfully. but when i refresh the browser page i get 404 error: This page could not be found.

as i understand the Sell page is in root dictionary and when i refresh browser, browser can't find the page at /sell/SM-S-589251/ URL.

is there any way to solve that?

thanks

nandorojo commented 3 years ago

It's because of the as prop. You need to add a page in the sell folder, such as sell/[id].

Then, in Link, add params={{ id: some-string }}.

You should read about next routing from their docs to better understand how it works.

mojtabahub commented 3 years ago

Hello,

is there anyway to open Link in web browser blank tab?

Thanks