-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useSession() return null after Internationalized Routing, unless I refresh the page. #2420
Comments
I have a similar issue! I am using After switching the locale, the The I would hope the session would also be kept between locales, just like it is kept between page navigations... I have no idea why this is happening, and if this behavior is normal. |
This may be an issue with the Can you confirm if this tracks with what you're both seeing? |
I solved my issue by wrapping all my context providers, except the So the weird undefined session behavior was caused by putting the auth provider inside the i18n wrapper. So don't do that. |
Yes, can confirm it's a In terms of code for const MyApp = ({ Component, pageProps }: AppProps) => {
return (
//...Component
);
};
const AppWithI18n = appWithTranslation(MyApp);
const AppWithAuth = (props: AppProps) => (
<Provider session={props.pageProps.session} >
<AppWithI18n {...props} />
</Provider>
)
export default AppWithAuth;
|
It work for me. Thank you |
Description 🐜
session is null after Internationalized Routing. Then if I refresh the current page, the session will return without problem;
Is this a bug in your own project?
Yes
How to reproduce ☕️
In one page or component I have the following code:
In a page
When I was already logined. And then click the
I18nLink
, the page will transit to the newlocate
without problem, but the session will be missing. Hence<div> session does not exist </div>
displayed.My current workaround:
instead of using next
router
, just simply usewindow.location = \newLocateUrl
to hard refresh the page.Note:
I was using
useSession()
to conditionally render certain components. If this wasn't a right way to do so, just let me know.Screenshots / Logs 📽
No response
Environment 🖥
Ubuntu
Windows 10
Contributing 🙌🏽
Yes, I am willing to help solve this bug in a PR
The text was updated successfully, but these errors were encountered: