Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

nextjs: TypeError: Cannot read properties of null (reading 'push')

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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>```

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading