This generic component is useful if you are creating your own ui library and you want your components accept not only the props you want them to have, but also all the native props. for example you want yourButton
component to accept and auto complete the eventHandlers, aria-props and stuff w/out specifying'em.
importReactfrom"react";constdefaultProps={tag:"section",};typeProps=React.HTMLAttributes<HTMLElement>&typeofdefaultProps&{tag:React.ElementType;className:string;cssModule?:CSSModule;}constHtml:React.FC<Props>=(props)=>{const{tag:Tag,...attributes}=props;return<Tag{...attributes}className={classes}/>;};Section.defaultProps=defaultProps;exportdefaultHtml;
now when you create your curstom button you'll see it will accept the props you set and also the "native props"
<Htmltag="button"onClick={e=>{e.preventDefault();}}/>
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse