Check out React 18's useExternalStore hook with TypeScript and generics

2024 ж. 20 Мам.
21 693 Рет қаралды

Code: github.com/jherr/syncexternal...
👉 Practical Module Federation Book: module-federation.myshopify.c...
👉 No BS TS (The Book): no-bs-ts.myshopify.com/
👉 I'm a host on the React Round-Up podcast: devchat.tv/podcasts/react-rou...
👉 Don't forget to subscribe to this channel for more updates: bit.ly/2E7drfJ
👉 Discord server signup: / discord
👉 VS Code theme and font? Night Wolf [black] and JETBrains Mono
0:00 Introduction
1:00 Project Recap
9:02 Typescript Setup
11:24 Converting The Store
13:24 Converting The Components
15:40 Removing Context
18:55 Moving useStore to the Store
21:19 Typescript Generics 101
26:30 Making useStore Generic
27:11 Making The Whole Store Generic
28:33 Deriving The Store Type
29:15 Outroduction
#react18 #useExternalStore

Пікірлер
  • You're making a big difference in many people's lives by providing this valuable content at no cost. Thank you, truly.

    @dominicanfrankster@dominicanfrankster Жыл бұрын
    • Thanks! I'm definitely starting to feel that. It's an honor.

      @jherr@jherr Жыл бұрын
    • indeed, I only recently start consuming this amazing content. And unlike other web related content out there, the takeaway here is just informational/facts that can be found in the docs, it actually teach you how to think and reason and why.

      @user-pm9xy2bj7p@user-pm9xy2bj7p Жыл бұрын
  • Thank you Jack for producing such an amazing quality content. I'm positive your teachings alone will kick-start the careers of many new developers. Perfect narration. Explanations are on point. Every sentence gives the right information, so we the mortals can chew on and be able to follow through. So glad i found your channel. Its pure gold!

    @TheDarkOneSC2@TheDarkOneSC2 Жыл бұрын
  • Pure gold. You are making TS so approachable...

    @Booyamakashi@Booyamakashi Жыл бұрын
  • Thank you for making this. I've been waiting for the tutorials to just start doing everything in TypeScript - that's what we all are writing anyway.

    @jeresalem@jeresalem Жыл бұрын
  • Thanks Man, I really appreciate your efforts to make these conceptual video and other analysis videos.

    @sadev0@sadev0 Жыл бұрын
  • Learning so much from your channel, thank you Jack Herrington!! 🙌 Absolutely love Typescript 🥳

    @utsavojha2953@utsavojha2953 Жыл бұрын
  • Thank you very much Sir for such a golden content. Really appreciate the work you're doing! I feel motivated by watching your videos.

    @namanparashar3982@namanparashar3982 Жыл бұрын
  • Great breakdown of generic types!

    @pfisste@pfisste Жыл бұрын
  • Thanks for this awesome tutorial

    @kasvith@kasvith Жыл бұрын
  • Thanks for another great video! Learn and have fun with Jack

    @AlexUnderCMYK@AlexUnderCMYK Жыл бұрын
  • My first comment on the tech channel! I'm also a big fan of React and TypeScript.Though I've seen a lot of your videos from when the channel has very few views It's the first time I commented! Always awesome content gives me and everyone tons of value without any cost. The view is incrementing quickly. I'm not surprised because you desired it, Sir!

    @nguyencong612@nguyencong612 Жыл бұрын
  • I love Typescript! Redux on NodeJS does not come with useSelector because it's a React thing, so I made my own and it works soooo good. No more fighting to get data in a background task that doesn't originate from a request. I don't care how much people hate on redux, I love it, I'll happily take the hit of boilerplating because it JUST works 😁

    @Stoney_Eagle@Stoney_Eagle Жыл бұрын
  • Another banger. Thanks Jack!

    @kettenbach@kettenbach Жыл бұрын
  • Such a nice Content to mid-senior level engineers 😁 totally worth it🔥

    @abhishekvishwakarma9045@abhishekvishwakarma9045 Жыл бұрын
  • thank you ❤

    @alirezaarttam3344@alirezaarttam3344 Жыл бұрын
  • Grand master 🔥🖤

    @allaithbitar1199@allaithbitar1199 Жыл бұрын
  • No I have no better way to expain it especially the Generics. It's a good idea to start from JS and convert to TS. It'll help both in understanding it better and appreciating the reliablility of code after adding TypeScript. And ... ... I love those utility types :)

    @mortezatourani7772@mortezatourani7772 Жыл бұрын
    • I agree, always GET IT WORKING first, then worry about the types.

      @jherr@jherr Жыл бұрын
  • Thank You very much for this info-tutorial. One request, using an external json object used as value in multi-step multi page form.

    @pareshsolanki929@pareshsolanki929 Жыл бұрын
  • Love to get pinned from you sir! Definitely recommend my colleagues about this channel lately!

    @samyogdhital@samyogdhital Жыл бұрын
  • LOVELY!!! Great to see doing things in Typescript. Question: when importing the 'type', do we have to do `import { type ValueStore } from ...`? Can't we directly do `import { ValueStore } from ...`?

    @farzadmf@farzadmf Жыл бұрын
    • You can. Adding the type is slightly more explicit. Totally optional though.

      @jherr@jherr Жыл бұрын
    • Great, thanks for the reply. Hoping to see more Typescript videos 🙂

      @farzadmf@farzadmf Жыл бұрын
    • @@jherr Don't you need the import with type since you export using type: export type ValueStore = ... ?

      @moritz22@moritz22 Жыл бұрын
  • Please give a video of nx nestjs and nextjs app deployed on vercel .its help for us.

    @mushfiqurtanim5164@mushfiqurtanim5164 Жыл бұрын
  • How did you do this cool text highlighting in beginning? Is it a VS code plugin that can do this? 🙂

    @TypeScriptTV@TypeScriptTV Жыл бұрын
    • There is none. That's custom code I made for the videos that does that work. And it's not in VS Code.

      @jherr@jherr Жыл бұрын
    • @@jherr understood. Looks very cool! Thanks for putting all this effort in. 👍

      @TypeScriptTV@TypeScriptTV Жыл бұрын
    • @@TypeScriptTV thanks. i need to make the workflow easier. i think the result it pretty good and makes complex code paths a little easier to understand.

      @jherr@jherr Жыл бұрын
  • Can you please do a video on Qwik Js?

    @jaymartinez311@jaymartinez311 Жыл бұрын
  • Can you create a tutorial series about developing a small web framework from scratch with Vite(something like Astro)

    @kasvith@kasvith Жыл бұрын
  • note to self: utility type -> deriving a type -> ReturnType . Oof!

    @alvarobyrne@alvarobyrne Жыл бұрын
  • Man can u react basic to advanced tutorial ,your all content so much advanced level

    @brajagopalmukherjee1588@brajagopalmukherjee1588 Жыл бұрын
    • Pls where can I find it?

      @simonkalu@simonkalu Жыл бұрын
    • kzhead.info/channel/PLNqp92_EXZBJ4CBroxVBJEpAXoz1g-naZ.html

      @jherr@jherr Жыл бұрын
  • {Sigh}, and I used to think "x = x + 1" would do it, for a counter on a web page ;(

    @lkd982@lkd982 Жыл бұрын
  • thanks, you forgot to upload code to git

    @user-tt3bc7yk8r@user-tt3bc7yk8r Жыл бұрын
    • Whoops. Fixed. Thanks for the heads up.

      @jherr@jherr Жыл бұрын
  • First viewer 🎉

    @SalmanMohammed043@SalmanMohammed043 Жыл бұрын
  • I know.. that background its fake :)

    @lkd982@lkd982 Жыл бұрын
  • This react shit going into infinity unnecessary! You need one year of time to just try every React Hook. If React continue to develop bullshit, will became as Angular. Every framework will die when developers cant keep track of it! This is easy solvable in plain react using context, but, look, another hook! I code in React almost 5 years, and this really starts to bothering me!

    @zlackbiro@zlackbiro Жыл бұрын
    • They did not remove useContext, you can still do your way. That's just easier and more optimized.

      @christianferrario@christianferrario Жыл бұрын
    • have you given up yet, I only use react because of Shopify framework called Polaris, but it got so restrictive lately, that I'm starting to think to rewrite everything in Svelte.

      @DaviAreias@DaviAreiasАй бұрын
KZhead