Created
December 20, 2023 04:27
-
-
Save andria-dev/81731fb29251d340c7a8abc9321ee4d1 to your computer and use it in GitHub Desktop.
React Tag Prop Pattern
This file contains 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
// You can also use TypeScript types to make the rest of ...props match | |
// what the HTML props or component props would be for that tag. | |
function Confetti({ tag: Tag, options, ...props }) { | |
const nodeRef = useRef(null); | |
/* logic */ | |
return <Tag ref={nodeRef} {...props}>{/* stuff */}</Tag>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment