next js referenceerror window is not defined code example
Example: next js referenceerror window is not defined
// try this for solved this issue
// components teritory
function Alert() {
return <div>{window.confirm('apakah anda belum makan ?') ? window.alert('ya') : window.alert('sudah')}</div>
}
export default Alert
// pages teritory
import dynamic from 'next/dynamic'
const AlertView = dynamic(() => import('../components/Alert'), { ssr: false })
function Alert() {
return (
<div>
<AlertView />
</div>
)
}
export default Alert