例えばButtonだとするとこんな感じ。
import { Button, ButtonProps} from "@/components/ui/button"; type Props = { children: ReactNode; isLoading: boolean; } & ButtonProps; export const LoadingButton = forwardRef<HTMLButtonElement, Props>({ children, isLoading, ...props}, ref) => { return ( <Button {...props} ref={ref}> {isLoading && <LoadingIcon>} {children} </Button> ); }
react v19 だとforwardRefいらなくなるらしいけどね!