next js windows undefined code example
Example: next js windows undefined
// 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