mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
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
18 lines
299 B
TypeScript
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>
|
|
)
|
|
}
|