Skip to content

Instantly share code, notes, and snippets.

@turbod
Created July 28, 2023 08:13
Show Gist options
  • Save turbod/a6a2e1cacf859e6971d8a8315b1312b2 to your computer and use it in GitHub Desktop.
Save turbod/a6a2e1cacf859e6971d8a8315b1312b2 to your computer and use it in GitHub Desktop.
import { OtherComponent } from "./other-component";
import React, { useRef, ElementRef } from "react";
// Pass it in via typeof!
type OtherComponentRef = ElementRef<typeof OtherComponent>;
const Component = () => {
const ref = useRef<OtherComponentRef>(null);
return <OtherComponent ref={ref}>Hello</OtherComponent>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment