Skip navigation
⚛️ React + Typescript tip:
0:00 / 0:51

⚛️ React + Typescript tip:

George Moller

@_georgemoller118K followers

Visit on X
1,067 likesDownloadOriginal post

77,712 views

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

12 Comments

Comments from the original post on X (Twitter)

  • George Moller's profile picture

    @_georgemoller

    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 ↓

    4 likes

  • Pavel Romanov's profile picture

    @pavl_ro

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

    2 likes

  • George Moller's profile picture

    @_georgemoller

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

    1 like

  • Web-Dev-Codi's profile picture

    @WebDevCodi

    Typescript version ohhhh yeah. Nice 👍

    1 like

  • George Moller's profile picture

    @_georgemoller

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

    1 like

  • Shripal Soni's profile picture

    @codewithshripal

    Loved this tip 🤩

    1 like

  • George Moller's profile picture

    @_georgemoller

    Glad you liked it Shripal!

    1 like

  • NORMAL's profile picture

    @NORMALPICTURES

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

    1 like

  • freddie's profile picture

    @frederic_ooo

    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

    1 like

  • P4R4NO1D73's profile picture

    @p4r4n01d73

    what tool do you use for animation ?

  • satonin's profile picture

    @vsatonin

    Wtf 🥴

  • Parth Prajapati's profile picture

    @iam_daparth

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