React and TypeScript

React and TypeScript Polymorphic Components Exercise

This course has been updated! We now recommend you take the React and TypeScript, v2 course.

Check out a free preview of the full React and TypeScript course:
The "Polymorphic Components Exercise" Lesson is part of the full, React and TypeScript course featured in this preview video. Here's what you'd learn in this lesson:

Students are instructed to create a polymorphic component text element that can be passed an as prop using the pattern from the previous example.

Get Unlimited Access Now

Transcript from the "Polymorphic Components Exercise" Lesson

>> We're gonna do another kind of simplified version of this, which is I kind of mentioned this before, is we've got this text element. And right now for the text element, it always returns a div, we wanna make a semantically better text element. Where we could pass in as prop in there, and as you'd be like as a paragraph tag, as a span.

[00:00:23] As I don't know article, whatever you wanna pass text into. We wanna just make it so we're using the same pattern that we use from the buttons with this text property. And give it a shot and try to cuz it's a lot, I think the act of kind of going through it will cement it into your brain and then we'll review it together as a team.