Created
May 4, 2024 04:44
-
-
Save amitasaurus/b03e2d9d302bdc4884635521e9a3b7b4 to your computer and use it in GitHub Desktop.
forwardRef simple syntax
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
interface MyComponentProps { | |
// Your component props here | |
} | |
const MyComponent = forwardRef<HTMLInputElement, MyComponentProps>( | |
(props, ref) => { | |
// Render your component with the ref attached to the desired element | |
return <input ref={ref} {...props} />; | |
} | |
); | |
export default MyComponent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment