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

Function Button

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected