next js referenceerror window is not defined

Solutions on MaxInterview for next js referenceerror window is not defined by the best coders in the world

showing results for - "next js referenceerror window is not defined"
Kylee
04 Jan 2019
1// try this for solved this issue
2
3// components teritory
4function Alert() {
5  return <div>{window.confirm('apakah anda belum makan ?') ? window.alert('ya') : window.alert('sudah')}</div>
6}
7
8export default Alert
9
10
11// pages teritory
12import dynamic from 'next/dynamic'
13
14const AlertView = dynamic(() => import('../components/Alert'), { ssr: false })
15
16function Alert() {
17	return (
18		<div>
19			<AlertView />
20		</div>
21	)
22}
23
24export default Alert