Skip navigation
๐Ÿ”ฅ TypeScript + React Tip ๐Ÿ”ฅ
0:00 / 1:37

๐Ÿ”ฅ TypeScript + React Tip ๐Ÿ”ฅ

Joe Previte

@jsjoeio40K followers

Visit on X
230 likesDownloadOriginal post

54,357 views

๐Ÿ”ฅ TypeScript + React Tip ๐Ÿ”ฅ I've stopped using React.FC to type my Function Components. Here's why:

21 Comments

Comments from the original post on X (Twitter)

  • Pedro Figueiredo's profile picture

    @P_FFigueiredo

    I was using `React.VFC<Props>` which was basically `React.FC` without the children prop, but since React v18, it doesn't have the children anymore, so, I still think that `React.FC` is a good alternative to type your components in a simple manner. ๐Ÿ‘

    4 likes

  • Joe Previte's profile picture

    @jsjoeio

    might have to redo the video then ๐Ÿคฃ does the other downside still apply related to generic props?

    1 like

  • Pedro Figueiredo's profile picture

    @P_FFigueiredo

    Yap, that's a nice one, other than that, I'd say there is another super minor and perhaps opinionated downside for `React.FC/VFC`, which is, they also allow the old ways of defining prop types, meaning: - propTypes - defaultProps And I certainly don't want people using those ๐Ÿ˜…

    1 like

  • Joe Previte's profile picture

    @jsjoeio

    Lol ahh okay. Well good to know then it still isn't the best way to type components (I also wouldn't want people to use propTypes or defaultProps)

    1 like

  • โšก๏ธFederico (rawnly)'s profile picture

    @fedevitaledev

    Children has been removed from FC since react 18 ๐Ÿฅฒ

    1 like

  • Joe Previte's profile picture

    @jsjoeio

    ๐Ÿ˜…๐Ÿ˜…๐Ÿ˜…๐Ÿ˜…

  • Kishore Andra (KcH)'s profile picture

    @kishore_kch

    @tscoursedotcom This one is a cool video, Joe is killing with expressions ๐Ÿ˜ ....

    1 like

  • Joe Previte's profile picture

    @jsjoeio

    @tscoursedotcom haha thanks Kishore! Glad you liked it ๐Ÿ™

  • Kishore Andra (KcH)'s profile picture

    @kishore_kch

    @tscoursedotcom absolutely Joe ๐Ÿ’ฏ, if it was an YT video the jump from chair reaction would be the ultimate thumbnail ๐Ÿ˜‰

    1 like

  • Jake Moreland's profile picture

    @jakeymoreland

    removed, i believe you can then utilise PropsWithChildren if you wish to then include the broad acceptance of children whilst still using FC

    1 like

  • Joe Previte's profile picture

    @jsjoeio

    moving this to top of replies ๐Ÿ‘‡ may have to make a follow up video lol

    1 like

  • Ross McIntyre's profile picture

    @rossmci

    children was removed from React.FC in React 18, so that's no longer an issue.

    1 like

  • Sujal Shah โœฆ's profile picture

    @sujal_shah10

    Thanks for this wonderful explaination!

    1 like

  • Joe Previte's profile picture

    @jsjoeio

    Glad you enjoyed it :D

    1 like

  • Khairallah AL-Awady's profile picture

    @eng_khairallah1

    Great tip, Joe!

    1 like

  • Talha Altฤฑnel's profile picture

    @mr_wormhole

    mega cursed

    1 like

  • Peter Piekarczyk (๐Ÿฅง๐Ÿš—๐Ÿฅ)'s profile picture

    @peterpme

    Wow I've been doing this for months out of my lack of desire to look into how to do it correctly ๐Ÿ˜‚

  • Alejandro's profile picture

    @BalariTheZombie

    There are also some helpful utility types like Omit, Exclude, Pick

  • Incalapabler's profile picture

    @incalapabler

    I really hate having too many exceptions. How are beginners going to learn when thereโ€™s deprecated code everywhere?

  • Joe Previte's profile picture

    @jsjoeio

    @veryfastsimba apparently it was removed in React 18 so this video may be outdated ๐Ÿคฃ

    1 like