mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
29 lines
677 B
JavaScript
29 lines
677 B
JavaScript
'use client'
|
|
|
|
import { useState, Suspense } from 'react'
|
|
import { unauthorized } from 'next/navigation'
|
|
import ForbiddenTrigger from './unauthorized-trigger'
|
|
|
|
export default function Root({ children }) {
|
|
const [clicked, setClicked] = useState(false)
|
|
if (clicked) {
|
|
unauthorized()
|
|
}
|
|
|
|
return (
|
|
<html className="root-layout-html">
|
|
<body>
|
|
<Suspense fallback={<div>Loading...</div>}>
|
|
<ForbiddenTrigger />
|
|
</Suspense>
|
|
<button id="trigger-unauthorized" onClick={() => setClicked(true)}>
|
|
Click to unauthorized
|
|
</button>
|
|
{children}
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|
|
|
|
export const dynamic = 'force-dynamic'
|