Loading video...

Video Failed to Load

Go Home

⚛️ React + Typescript tip: Creating dynamic prop types for components with Discriminated Unions ↓

77,657 views • 2 years ago •via X (Twitter)

12 Comments

George Moller's profile picture
George Moller2 years ago

I've been working professionally with React for more than 8 years and I compiled all my knowledge into 100+ infographics and 70+ video tutorials just like this one. Check them out ↓

Pavel Romanov's profile picture
Pavel Romanov2 years ago

One of the best react + typescript tips. It makes the overall code flow so much easier and enforce specific rules whenever needed.

George Moller's profile picture
George Moller2 years ago

I agree, this is such a common use case for React developers! it's great to have a way to type it.

Web-Dev-Codi's profile picture
Web-Dev-Codi2 years ago

Typescript version ohhhh yeah. Nice 👍

George Moller's profile picture
George Moller2 years ago

oh yeah, typescript + react tips are coming my friend!

Shripal Soni's profile picture
Shripal Soni2 years ago

Loved this tip 🤩

George Moller's profile picture
George Moller2 years ago

Glad you liked it Shripal!

NORMAL's profile picture
NORMAL2 years ago

Where’s the discrimination here ? Dang libs 🇺🇸 🍺

freddie's profile picture
freddie2 years ago

a good idea is to keep all members of the union with the same keys, but set the ones that aren’t supposed to be there as *optional never*. this will help you when writing the body of the component without needing to check for the existence of properties

P4R4NO1D73's profile picture
P4R4NO1D732 years ago

what tool do you use for animation ?

satonin's profile picture
satonin2 years ago

Wtf 🥴

Parth Prajapati's profile picture
Parth Prajapati2 years ago

A super tip! Really cannot imagine working in React + TS without this.

Related Videos