MCPcopy Create free account
hub / github.com/TanStack/query / Button

Function Button

examples/react/suspense/src/components/Button.tsx:4–26  ·  view source on GitHub ↗
({
  children,
  onClick,
}: {
  children: React.ReactNode
  onClick: any
})

Source from the content-addressed store, hash-verified

2import Spinner from './Spinner'
3
4export default function Button({
5 children,
6 onClick,
7}: {
8 children: React.ReactNode
9 onClick: any
10}) {
11 const [isPending, startTransition] = React.useTransition()
12
13 const handleClick = (e: any) => {
14 startTransition(() => {
15 onClick(e)
16 })
17 }
18
19 return (
20 <>
21 <button onClick={handleClick} disabled={isPending}>
22 {children} {isPending ? <Spinner /> : null}
23 </button>
24 </>
25 )
26}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected