Files
Hendrik LiebauandGitHub 4e0b1125a4 Improve error handling for headers/cookies/draftMode in 'use cache' (#81716)
This ensures that we show a proper error with an error stack
(potentially source-mapped) when accessing
`headers`/`cookies`/`draftMode` in `'use cache'`, even when caught in
user-land code. For `searchParams` (currently triggering a timeout
error) we'll need a slightly different solution, which will be handled
in a future PR.

The approach chosen here is somewhat temporary, as we'd like to
implement compile-time errors instead for accessing any kind of request
data in `'use cache'` functions. However, this would require a larger
change to our bundlers.

closes NAR-201
2025-07-16 23:27:05 +02:00

18 lines
299 B
TypeScript

'use client'
import React from 'react'
import { useFormStatus } from 'react-dom'
export function Button({
children,
id,
}: React.PropsWithChildren<{ id: string }>) {
const { pending } = useFormStatus()
return (
<button id={id} disabled={pending}>
{children}
</button>
)
}