Strongly Typed Refs

Learn how to support stronger ref types in polymorphic component implementation.

We have a typed ref implementation of our polymorphic component. However, our solution still isn’t as strongly typed as we would like. There's an edge case we haven't covered yet.

Incorrect ref support

Consider the following scenario, where a user passes the wrong element ref to our component. We want to throw a TypeScript error when a user does this.

Get hands-on with 1400+ tech skills courses.