Open History to see the last commit
1import React from "react";
2β
3import Spinner from "./Spinner";
4β
5export default function Button({ children, onClick }) {
6 const [isPending, startTransition] = React.useTransition();
7β
8 const handleClick = (e) => {
9 startTransition(() => {
10 onClick(e);
11 });
12 };
13β
14 return (
15 <>
16 <button onClick={handleClick} disabled={isPending}>
17 {children} {isPending ? <Spinner /> : null}
18 </button>
19 </>
20 );
21}