Jack Herrington
Jack Herrington
  • Видео 423
  • Просмотров 12 456 272
React 19's useOptimistic: EVERYTHING you NEED to know
useOptimistic makes your pokey backend feel fast with optimistic updates to your UI. It's simple to use, but we'll covert the gotcha, as well as how to use it with React Query and also whether or not you should use it with a state manager.
Code: github.com/jherr/useOptimistic-video
👉 Upcoming NextJS course: pronextjs.dev
👉 Don't forget to subscribe to this channel for more updates: bit.ly/2E7drfJ
👉 Discord server signup: discord.gg/ddMZFtTDa5
👉 VS Code theme and font? Night Wolf [black] and Operator Mono
👉 Terminal Theme and font? oh-my-posh with powerlevel10k_rainbow and SpaceMono NF
00:00 Introduction
00:50 Creating a simple API server
03:05 Setting up Pico CSS
04:40 Connecting to the API server
0...
Просмотров: 6 207

Видео

Big Suspense Changes in React 19: Explained In Code
Просмотров 22 тыс.День назад
What seems like a minor change to suspenses in React 19 is getting major pushback because of the impact it has on the way we load data into Single Page Applications. Code: github.com/jherr/react-19-suspense-changes TkDodo's Blog Post on Suspense: tkdodo.eu/blog/react-19-and-suspense-a-drama-in-3-acts 👉 Upcoming NextJS course: pronextjs.dev 👉 Don't forget to subscribe to this channel for more up...
Radix Themes: Awesome New Components For NextJS
Просмотров 15 тыс.14 дней назад
The NextJS App Router's auto mode does a great job of figuring out when a page is static or dynamic, but how and when should you take control for yourself? Code: github.com/jherr/radix-pokemon Radix Themes: www.radix-ui.com/ WorkOS: workos.com/ AuthKit: www.authkit.com/ 👉 Upcoming NextJS course: pronextjs.dev 👉 Don't forget to subscribe to this channel for more updates: bit.ly/2E7drfJ 👉 Discord...
Beware of "auto" Mode in the NextJS App Router
Просмотров 15 тыс.21 день назад
The NextJS App Router's auto mode does a great job of figuring out when a page is static or dynamic, but how and when should you take control for yourself? Code: github.com/jherr/beware-of-auto Course: pronextjs.dev Where to go for project audits: www.liminal.sh/ 👉 Upcoming NextJS course: pronextjs.dev 👉 Don't forget to subscribe to this channel for more updates: bit.ly/2E7drfJ 👉 Discord server...
NextJS 15: React 19, Less Caching, Turbopack, Better Hydration Errors and MORE from Vercel Ship!
Просмотров 27 тыс.Месяц назад
NextJS 15 Release Candidate 0 is out and it's got so much good stuff. Let's take a look feature by feature and try them out to see what's in store for us. React 19! Caching is off by default! Super fast builds with Turbopack! Hydration errors you can actually debug! And much more! Let's jump in! Code: github.com/jherr/next-15-rc-0 Release Notes: nextjs.org/blog/next-15-rc 👉 Upcoming NextJS cour...
Stop Using useEffect With Redux!
Просмотров 23 тыс.Месяц назад
You shouldn't be using useEffect with your Redux store. It's splitting your business logic! Code: github.com/jherr/redux-listeners-video Course: pronextjs.dev Where to go for project audits: www.liminal.sh/ 👉 Upcoming NextJS course: pronextjs.dev 👉 Don't forget to subscribe to this channel for more updates: bit.ly/2E7drfJ 👉 Discord server signup: discord.gg/ddMZFtTDa5 👉 VS Code theme and font? ...
React Compiler: In-Depth Beyond React Conf 2024
Просмотров 73 тыс.Месяц назад
Is the React Compiler the most advanced frontend compiler? Let's dig in and see just what it's doing to our code! Compiler REPL: github.com/jherr/compiler-repl Meta REPL: playground.react.dev/ Rules of React: react.dev/reference/rules 👉 Upcoming NextJS course: pronextjs.dev 👉 Don't forget to subscribe to this channel for more updates: bit.ly/2E7drfJ 👉 Discord server signup: discord.gg/ddMZFtTDa...
No const! How NOT To Give A JavaScript Talk
Просмотров 60 тыс.Месяц назад
Let's talk a look at Ryan Florence's Epic Web Dev talk "Let Me Be" where he wants to convince us to use a lot more "let" in our JavaScript and a lot less const. Does he do a job convincing us? Are you convinced? And if you are do you think you could defend that position to your coworkers? And what can we learn for our own presentations? Let's find out! Let Me Be talk: www.epicweb.dev/talks/let-...
Next-Auth v5 is Almost Here! Learn it Fast on the NextJS App Router TODAY!
Просмотров 26 тыс.Месяц назад
Next-auth is an easy way to get started with authentication in your NextJS App Router application. Let's get it set up, and see how to secure routes, server actions, API routes and client and server API requests! Code: github.com/jherr/next-auth-v5 👉 Upcoming NextJS course: pronextjs.dev 👉 Don't forget to subscribe to this channel for more updates: bit.ly/2E7drfJ 👉 Discord server signup: discor...
JS Built-in Signals In React and Svelte TODAY!
Просмотров 21 тыс.2 месяца назад
JavaScript could be getting built-in signals! A TC39 could unify how we manage state across React, Angular, Vue, Qwik, Solid, Vanilla... everywhere! Reading the TC39 proposal and talking about it is one thing, but let's see it in action, connecting two different frameworks on top of Astro. Code: github.com/jherr/signals-shopping-cart/blob/main/README.md Proposal: github.com/tc39/proposal-signal...
Javascript Array and Object Cloning: Shallow or Deep?
Просмотров 11 тыс.2 месяца назад
Should you clone objects and arrays shallow or deep? What is the difference and when does it matter? Let's dig into Javascript Array and Object cloning so that we can learn once and for all, why and when to use deep or shallow cloning. 👉 Upcoming NextJS course: pronextjs.dev 👉 Don't forget to subscribe to this channel for more updates: bit.ly/2E7drfJ 👉 Discord server signup: discord.gg/ddMZFtTD...
Declarative Routes for NextJS and React-Router: DRY Routing
Просмотров 26 тыс.2 месяца назад
Why settle for hard-coded link strings and URLs for fetch calls? Let's build a declarative routing system on top of NextJS's router (and the React-Router), to give us write once and never change routing. Code: github.com/jherr/nextjs-declarative-routing NPM: www.npmjs.com/package/declarative-routing 👉 Upcoming NextJS course: pronextjs.dev 👉 Don't forget to subscribe to this channel for more upd...
Are You In A React Cult?
Просмотров 29 тыс.2 месяца назад
React is a huge community. Misconceptions and bad information around useMemo, useCallback, the spread operator, React class components, Redux and more spread like wildfire and create cult-like followings who swear by this stuff. Let's take down a few of these big misconceptions. 👉 Upcoming NextJS course: pronextjs.dev 👉 Don't forget to subscribe to this channel for more updates: bit.ly/2E7drfJ ...
Finally Fix Your Issues With JS/React Memory Management 😤
Просмотров 81 тыс.3 месяца назад
Finally Fix Your Issues With JS/React Memory Management 😤
Pigment-CSS: Material-UI Fixed on NextJS and React 19
Просмотров 10 тыс.3 месяца назад
Pigment-CSS: Material-UI Fixed on NextJS and React 19
Tailwind CSS V4 For NextJS, Astro and Vite TODAY
Просмотров 14 тыс.3 месяца назад
Tailwind CSS V4 For NextJS, Astro and Vite TODAY
Is Tanstack Router Better Than React-Router?
Просмотров 33 тыс.3 месяца назад
Is Tanstack Router Better Than React-Router?
React Hook Form & React 19 Form Actions, The Right Way
Просмотров 43 тыс.3 месяца назад
React Hook Form & React 19 Form Actions, The Right Way
Are Your React Components Too BIG?
Просмотров 23 тыс.4 месяца назад
Are Your React Components Too BIG?
Mastering Micro-Frontends With RSpack and Module Federation
Просмотров 12 тыс.4 месяца назад
Mastering Micro-Frontends With RSpack and Module Federation
Five React App Killing Anti-Patterns 🪦😱
Просмотров 32 тыс.4 месяца назад
Five React App Killing Anti-Patterns 🪦😱
Easy Multi-tenant NextJS Apps With Clerk
Просмотров 23 тыс.4 месяца назад
Easy Multi-tenant NextJS Apps With Clerk
Are RSCs and NextJS Really That Bad?
Просмотров 45 тыс.4 месяца назад
Are RSCs and NextJS Really That Bad?
Alpine, HTMX, Astro Stack Wordle App With Full Source!
Просмотров 12 тыс.5 месяцев назад
Alpine, HTMX, Astro Stack Wordle App With Full Source!
Hiring Secrets of a Netflix Software Engineering Manager
Просмотров 13 тыс.5 месяцев назад
Hiring Secrets of a Netflix Software Engineering Manager
HTMX For React Developers in 10 Minutes
Просмотров 40 тыс.5 месяцев назад
HTMX For React Developers in 10 Minutes
Ranking 6 Coding AIs Transforming Web Development in 2024
Просмотров 9 тыс.5 месяцев назад
Ranking 6 Coding AIs Transforming Web Development in 2024
How To Debug Broken APIs
Просмотров 6 тыс.6 месяцев назад
How To Debug Broken APIs
13 Figma To React Converters Ranked
Просмотров 25 тыс.6 месяцев назад
13 Figma To React Converters Ranked
StyleX: Meta's Solution To CSS At Scale
Просмотров 41 тыс.6 месяцев назад
StyleX: Meta's Solution To CSS At Scale

Комментарии

  • @fadfooood
    @fadfooood 21 час назад

    Amazing video as usual ❤️

  • @asdqwe4427
    @asdqwe4427 22 часа назад

    Getting seriously fatigued by new react features

  • @thisweekinreact
    @thisweekinreact 23 часа назад

    Great video! 2 extra notes: - React 19 automatically reset forms on actions, or you can call new ReactDOM.requestFormReset() API when using onKeyUp - React transitions need to be async due to lack of support of AsyncContext in browsers. setState calls after the await won't be part of the transition, you need to nest an extra startTransition call to make them part of the current transition Will send a Twitter DM, easier to explain :D

  • @arvind6151
    @arvind6151 День назад

    Keep going Jack, really useful to see RC updates like this. 👍

  • @Luisllaboj19
    @Luisllaboj19 День назад

    They extrended "useTransition" hook to accept async functions now :D

    • @Luisllaboj19
      @Luisllaboj19 День назад

      Also the form inputs areautomatically cleaned up when the task resolves

  • @marroos5440
    @marroos5440 День назад

    Hello, i am still learning and i've checked useActionState from latest version of NextJs and it looks like improved useFormState to me, so i would like to use it for pending/error states when i use server action (let's say addTodo). Why should i use useOptimistic hook too? I mean when i press Button in form with server action in useActionState i can add loading/ spinner status while isPending is active and/or error text once error occurs. If everything goes well, new todo is added to list and displayed. I am getting confused with all those new hooks and changes, so i would like to know what is the point of useOptimistic in scenario i've described. Does useOptimistic work like placeholder for data showing: once it is successful, data stays, and if not, they disappear? Ty :-)

    • @jherr
      @jherr 22 часа назад

      Yes, that's the way useOptimistic works as shown in the video. It looks like useOptimistic is a best match for smaller operations; A like/subscribe button, for example.

  • @coinvest0
    @coinvest0 День назад

    Very detailed explanation, thank you very much!

  • @xxXAsuraXxx
    @xxXAsuraXxx День назад

    Waiting for useNextJsDepression()

  • @ballingt
    @ballingt День назад

    Fantastic presentation and content as usual, love these.

  • @ballingt
    @ballingt День назад

    re 11:34 addNewTodo() will run synchronously up to the first await, so I believe that's why setOptimisticTodos works

  • @usmansbk
    @usmansbk День назад

    Apollo client

  • @ErikBongers
    @ErikBongers День назад

    The issue is that in JavaScript you can't distinguish between a const pointer and a const value. In JS, it's always just the pointer that is const, never the value.

    • @jherr
      @jherr 22 часа назад

      True. But some assurance is better than none.

  • @pedromenezes7175
    @pedromenezes7175 День назад

    As always, pretty insightful video with clear explanations and examples! Thanks for covering as much as possible in such a concise video!

  • @rayevo8mr209
    @rayevo8mr209 День назад

    Is there a way to optimistically perform more than one CRUD action? I ran into this problem where i had managed state but need to add / remove etc optimistically but the logic was honestly getting out of control compared to using something like use swr or zustand for state management.

    • @jherr
      @jherr 22 часа назад

      Sure, in this model you can do as much work in the action as you want, and set as many optimistic values as you want. The nice thing is that you get the automatic rollback when things fail.

  • @nazarocean
    @nazarocean День назад

    Thanks for the useful video!

  • @yashsolanki069
    @yashsolanki069 День назад

    When will the pronextjs course be available??

    • @jherr
      @jherr 22 часа назад

      It's in final priduction right now. So it's actually out of my hands.

    • @yashsolanki069
      @yashsolanki069 21 час назад

      @@jherr awesome!! Looking forward to it. I hope pricing is considered with PPP. Otherwise i would have to rob a bank here in india to get this purchase done.😂

  • @gerkim3046
    @gerkim3046 День назад

    wtf is the difference between addTodo() vs addNewTodo()?

  • @hikarukun5126
    @hikarukun5126 День назад

    Tired of React

  • @rayyanalam4815
    @rayyanalam4815 День назад

    Can anyone let me know the theme?

  • @derSeega
    @derSeega День назад

    Okay, I'm not a big fan of this I think. I'm not feeling like this is enhancing the readability of the code to be honest. Updating the state manually and afterwards overriding it with the response is not adding more code than the useOptimistic, but everyone will understand what is happening. And I was hopeing we can have less hooks in react 19 not more 😒😒 Maybe some one can convince me

  • @reichenwald-gm4qd
    @reichenwald-gm4qd День назад

    I would be cool to show the all the extensions like console ninja you’re using

  • @denilsoncosta9837
    @denilsoncosta9837 День назад

    i used it in a app where has the car functionality and the UX become better when the user increment or decrement the quantity of a product.

  • @seyhaphan7319
    @seyhaphan7319 День назад

    I have problem when I want to display data with dynamic 50+ rows it so slow. Did you know what is problem ?

    • @jherr
      @jherr День назад

      You'd have to supply a lot more information than this to get help on your issue. Feel free to post your question on the Blue Collar Coder Discord server, but please READ and FOLLOW the #rules before posting.

  • @flippo_
    @flippo_ День назад

    Great vid as always! Correct me if I'm wrong but I believe with form action the input field should clear it self so you don't need that ref.current.value = ""? Tried to recreating it and it worked on my end at least, also I think the reason why the app "blew up" after you introduced useActionState was because the current action payload is the second argument not the first

  • @keepforever726
    @keepforever726 День назад

    Ew, what a mess these APIs are. Remix does all of this so much cleaner.

    • @jherr
      @jherr День назад

      I looked it up and Remix's "support" for optimistic UI is just a coding pattern you can lift (www.learnremix.io/learn-remix/optimistic-ui-with-remix#handling-errors-with-remix-and-optimistic-ui) that is kind-of supported by the Form. But there example at the end has a very jank likeCount - 1 setting of the useState if it fails... I don't see how that's better. Also, Remix (or React-Router) is built on top of React, so you'll get this hook either way with React-Router 7. Which will also give you server actions.

  • @abodiit
    @abodiit День назад

    Great video thanks Jack, one question though how you are doing the syntax highlights when you are explaining and rest of the code fade

    • @jherr
      @jherr День назад

      I do that manually in Screenflow as I'm assembling the video.

  • @mzimmma
    @mzimmma День назад

    PLEASE STOP USING STUPID BOOMERS TODO STUPID EXAMPLE.

  • @mzimmma
    @mzimmma День назад

    remember when optimistic functions used to be anti-user friendly. Now it's the time to be optimistic lier in your frontend till your backend requests return if they don't fail.

  • @PhilipAlexanderHassialis
    @PhilipAlexanderHassialis День назад

    Excellent video Jack as usual! What's your opinion on all the code tied with the useOptimistic/startTransition/useActionState/etc that we have to write just to get an optimistic update? Doesn't it seem a bit boilerplate-y?

    • @derSeega
      @derSeega День назад

      Thanks, I'm also not convinced this is enhancing the readability. Just more hooks to hide the obvious.

  • @matteo_gabriele
    @matteo_gabriele День назад

    Gotta love that Ttttsszzzustand pronunciation!

  • @ps14dd88
    @ps14dd88 День назад

    Looks like a little bit complicated/over engineered to implement a simple optimistic UI in a todo app

    • @PhilipAlexanderHassialis
      @PhilipAlexanderHassialis День назад

      My thoughts exactly. It's not that it doesn't work per se, but try to imagine this for a complicated form state and not a single value. Imagine a form with multiple fields, and even worse, imagine a form where some fields depend on other fields and the "detail" fields need to fetch new values depending on the "master" fields. A chaos all in all.

    • @porroapp
      @porroapp День назад

      Thats why we use RQ in production. Code is simpler and more maintainable.

    • @rayevo8mr209
      @rayevo8mr209 День назад

      It is mate, all the demos always show a simple scenario but in real web apps it's absolute chaos with this hook

  • @camilo5821
    @camilo5821 День назад

    cheers from Chile Jack!!

  • @sufiblade
    @sufiblade День назад

    They're not very optimistic if we'll use this implementation

  • @Caldaron
    @Caldaron День назад

    using that suspense properly handler reminds me of the bad old redux days. does react actually hire for overengineering?

  • @mpbros.official
    @mpbros.official 2 дня назад

    You are the best!!!

  • @patrickjreid
    @patrickjreid 2 дня назад

    Jack, i love your videos! I would love it if you did a review on tinybase. It seems like a very useful state manager specializing in offline first.

  • @lukei9772
    @lukei9772 2 дня назад

    just to be clear, just putting a sqlite.db file in your project wont work in production if you deploy to vercel right?

    • @jherr
      @jherr 2 дня назад

      Correct. Turso is a sqlite compatible remote database. So you can just change out the file URL for a Turso URL.

  • @fadfooood
    @fadfooood 2 дня назад

    I noticed the compiler is not memoizing functions from custom hooks. I had to useCallback my functions in my custom hooks to avoid rerenders. Any idea why?

    • @jherr
      @jherr 2 дня назад

      Is it not optimizing any custom hooks? Or just that one custom hook? If it's just that one then it's possible that the compiler assessed some issue with it that wouldn't allow for optimization. The compiler is very conservative. If it doesn't think it can safely optimize the code without a change in behavior it will just leave the component or hook as is.

    • @fadfooood
      @fadfooood 2 дня назад

      @@jherr Thank you for your reply. Yes I noticed it is not optimising any functions destructed from custom hooks. I thought the compiler will do so but when I brought back useCallback to memoize functions in custom hooks then components using these functions stopped re-rendering.

  • @dopetag
    @dopetag 3 дня назад

    That was heavy. Does memoization not create new map each time?

    • @jherr
      @jherr 2 дня назад

      No, the memoization function is a closure creator. It gets invoked once. Creates a local map. Then returns a function, which is the one we use, which uses that map to store promises.

    • @dopetag
      @dopetag 2 дня назад

      @@jherr oh, yes! Thanks for response. I see it now.

  • @spidfair0
    @spidfair0 4 дня назад

    I like that caching becomes more of an opt-in feature. What I'd like to know is if request memoization is also affected by this change. Deduping fetch calls of a single request was great as it reduced prop-drilling. If caching is off by default, does that also mean that deduping on a single request is also off?

    • @jherr
      @jherr 3 дня назад

      fetch de-duping during the request is a core feature of React 19, so it's still there. There is some talk that they will stop patching fetch in the future, so we might end up needing to import a specific fetch to get the de-duped behavior.

  • @IvanKleshnin
    @IvanKleshnin 4 дня назад

    He's right yet he selected a bad argument. It's not about mutability, it's about Bang for the Buck. The reasoning of an average Js.Joe is very "cheap", if soon there appears a feature that helps them to spot a code issue once in 10 years, in return requiring to postfix_ boolean variables with underscore... most JS coders would enthusiastically accept it, bragging about supposedly improved 'code quality'. They don't care about readability, they are extremely easy to buy into something stupid - like no other programming community. The same happened with == vs === when some vicious Java dude, for a joke, taught every frontender to mindlessly use ===, like `typeof s === "string"` where typeof always return a string. But millions of JS monkes keep stroking this extra character... because it's a ritual. The same happened with TS 'readonly' which adds tons of troubles for no gains. Respect to Ryan for standing against the crowd, albeit I'm not his follower, he's right in his attitude to frontenders en masse. const does not add anything useful, except a feeling of a false self-satisfaction. How often do you reassign variables in practice so const vs let becomes such an important distinction for a new keyword? So many self-proclaimed FP fanboys among JS coders, they have to use conditional expressions, don't they? Why not a dedicated keyword for floats vs ints? Not a keyword for natural numbers? They would, at least, be useful.

  • @user-wz4mi3fd4b
    @user-wz4mi3fd4b 4 дня назад

    I wonder how you would handle the selector if its an array of objects? Been wracking my head around how to handle that one. All the objects have a unique key so they could then be a selector for [idkey] : { // other objects }? Starting to realize how important data design is at a company where it was created organically so its a bit of a mess

    • @jherr
      @jherr 4 дня назад

      References are the way to handle change detection in React. That's how the entire system is built. If any element in the array changes then the array reference itself should change. And then you can detect changes to the complete array easily using Object.is with the current value and the previous value.

  • @MartinEide-sq8og
    @MartinEide-sq8og 4 дня назад

    Love htmx and astro. Alpine js was just that last missing reactivity part I was looking for. ❤

  • @kkjoe2677
    @kkjoe2677 4 дня назад

    For time1 and time2, can we put them in separate suspense and put all suspense under a suspenseList to ensure the waterfall and sequential rendering? If so, what makes the difference here?

    • @jherr
      @jherr 4 дня назад

      Give it a go. Putting them in their own suspenses will bring back the parallel behavior since the blocking is only the the context of a single suspense. I don't know if SuspenseList changes that behavior, but my hunch is not. FWIW, I haven't used SuspenseList. Also, given that Joe Savona has now also come out and said there will be a "good fix" I think we will get the old behavior back. Will it be the default? Who knows. But we should at least have some way to get the original behavior.

  • @AndreasSchlapbach
    @AndreasSchlapbach 4 дня назад

    Didn't like that some of the styling (like padding or margins) is in the components and some is in CSS. Preferring tailwind's unified tailwind approach.

  • @chorymiguel
    @chorymiguel 4 дня назад

    'prefer-const': 'off'

  • @ykl0919
    @ykl0919 4 дня назад

    Thank you for posting this video. It is such a treasure for people like me who mostly self-learned

  • @saramshshrestha7641
    @saramshshrestha7641 4 дня назад

    I just really love you. You might be one the best teacher out their.

    • @jherr
      @jherr 4 дня назад

      Thank you!

  • @KayandraJT
    @KayandraJT 5 дней назад

    Just like server components, the approach to hoisting promises makes sense to me. It's how I've been doing it for years. Data should be separated from rendering, this is how you avoid buggy applications.

  • @ngocquach9961
    @ngocquach9961 5 дней назад

    could you explain more about typescript apply for micro?

    • @jherr
      @jherr 4 дня назад

      There is a plugin now for TypeScript with federated modules. I haven't looked into how it works. But the approach that I've heard in the past is that when the federated module is created a sibling .d.ts file is created, zipped and deployed alongside the JS file for the module. Then when the hosting application is built the plugin pulls down the zipped .d.ts file before TSC compilation, and... viola. Types.