Skip to content

Instantly share code, notes, and snippets.

@andria-dev
Created December 20, 2023 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andria-dev/81731fb29251d340c7a8abc9321ee4d1 to your computer and use it in GitHub Desktop.
Save andria-dev/81731fb29251d340c7a8abc9321ee4d1 to your computer and use it in GitHub Desktop.
React Tag Prop Pattern
// 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