an example of how we can extend react custom component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// declare your component | |
import type { ComponentPropsWithoutRef } from 'react'; | |
interface ButtonProps extends ComponentPropsWithoutRef<"button"> { | |
label: string; | |
} | |
export function MyButton({ label, ...rest }: ButtonProps) { | |
return (<button><button {...rest} /></button>); | |
} | |
/// how to use it //////// | |
import {InputGroup, MyButton} from './com'; | |
export default function About() { | |
let [counter, setCounter] = useState<number>(100) | |
return <div>Hello | |
<MyButton label='test'> </MyButton> | |
</div> | |
} |
Comments