I use sweetalert2
for show popup:
export default function Home() {
const MySwal = withReactContent(Swal)
useEffect(() => {
MySwal.fire({
showConfirmButton: false,
customClass: {
container: "swalPopup"
},
html:<Link href={"/profile/dashboard"}><a>TEST</a></Link>,
})
}, []);
return ('<div>Home</div>')
}
After show opopup I clicked on TEST
and I get this error:
Unhandled Runtime Error
TypeError: Cannot read properties of null (reading 'push')
Call Stack
linkClicked
node_modules/next/dist/client/link.js (50:11)
onClick
node_modules/next/dist/client/link.js (200:16)
Without sweetalert2
, <Link>
work fine, but with sweetalert2
I get error
>Solution :
Please try to this;
<Button type="button" onClick={(e) => router.push('/profile/dashboard')}>
Test
</Button>
or
<Link href="/">
<a onClick={(e) => handleClick(e, "//profile/dashboard")}>Test</a>
</Link>```