Skip to content

Instantly share code, notes, and snippets.

@cuonghuynh
Created March 3, 2021 08:42
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 cuonghuynh/3d16a69542a262c725d8b0fdfe54203e to your computer and use it in GitHub Desktop.
Save cuonghuynh/3d16a69542a262c725d8b0fdfe54203e to your computer and use it in GitHub Desktop.
React pass custom prop to ForwardRef component
export const MySection = React.forwardRef<
HTMLDivElement,
{ myAttribute: boolean }
>(({ myAttribute }, ref) => {
return (
// your component
)
}
<MySection ref={mySectionRef} myAttribute={true} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment