-
Notifications
You must be signed in to change notification settings - Fork 50
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
Next/Link isn't working. #172
Comments
@meotimdihia You can't use the Next/Link component in Sweetalert2 React content because that content is not part of the Next.js page (element tree). The Next.js page is rendered in the context of the Next.js router, but the Sweetalert2 React content is not. The Next/Link component relies on having the Next.js router in context. I suggest that instead of using Next/Link you handle the import Router from "next/router";
<a
href="/day"
onClick={(e) => {
e.preventDefault();
Router.push("/day");
MySwal.close();
}}
className="font-semibold link"
> https://codesandbox.io/s/next-sweetalert2-bug-example-forked-df89o?file=/pages/index.js Of course to make things DRY and to separate concerns you could make a component for this. |
Closing because there's no action that can be taken in this project. That said, it would be great if Next/Link used the singleton Router directly instead of getting it from context. (But there may be some reason for that) |
Thanks for the solution. I am fine with using the next/router. |
Next/Link isn't working. This is an example:
https://codesandbox.io/s/next-sweetalert2-bug-example-3rx84
Related with the issue: vercel/next.js#16864
I don't really know If this is package or next.js problem.
The text was updated successfully, but these errors were encountered: