Optimistic UI in Remix

Поділитися
Вставка
  • Опубліковано 8 січ 2025

КОМЕНТАРІ • 52

  • @laptopuser5198
    @laptopuser5198 Рік тому +3

    High Quality content. Keep the remix coming.

  • @adiadiadi
    @adiadiadi Рік тому

    I'd often get tripped up by the useFetcher API in Remix. This helped deepen my understanding.
    thank you Sam!

  • @martinemanuel8239
    @martinemanuel8239 Рік тому +1

    Remix is such an amazing framework kudos for the project

  • @Gileno
    @Gileno Рік тому +2

    Great video. Deep enough to understand how optimistic ui on Remix works... It would be nice if you could show how to handle errors on optimistic ui as well. Thanks.

  • @planetmall2
    @planetmall2 Рік тому

    Seriously one of the best learning videos I have seen. I really appreciate this.

  • @VitorJustin
    @VitorJustin Рік тому +1

    Thanks for the lesson, Sam. Great content as usual.

  • @saurabh75prakash
    @saurabh75prakash 8 місяців тому

    Great tutorial on Optimistic UI and fetchers, thanks.

  • @vaibhavshringarpure8570
    @vaibhavshringarpure8570 Рік тому +1

    Hi Sam - Yet another great video. Nothing less can be expected from this channel.. You always try to explain it very nicely and easy to understand. Thanks for doing it. Appreciate it. Also wanted to say here that all your demo UI looks really sleek and thought-after... how do you come up with these project ideas and nice clean UI.. perhaps a video on how to approach a project from concept to final would be good to get some insights please. Thank you

    • @samselikoff
      @samselikoff  Рік тому +2

      Thanks for the kind words! The best advice for getting better at the design side of UI is to practice + recreate well-designed interfaces. Build up your taste over time and focus on the details. Refactoring UI helped me a lot here! I also spend about an hour in the Remix course on redesigning the Work Journal covering some design best practices along the way: buildui.com/courses/ship-an-app-with-remix/mobile-redesign
      Maybe I'll add some videos here on the topic if folks are interested!

    • @vaibhavshringarpure8570
      @vaibhavshringarpure8570 Рік тому

      Thank you kindly Sam

  • @anth0ni33
    @anth0ni33 6 місяців тому

    The useFetcher singleton approach has its applications. E.g.: When clicking a like button, you don't want it to send all the requests, you want just the last input.

  • @rodolphobravo298
    @rodolphobravo298 Рік тому

    Great video as usual, Sam!

  • @simonpoudyal2293
    @simonpoudyal2293 Рік тому +4

    Hey, in your future videos, is it possible to show your keypresses on screen? Recently started learning vim motions and the way you navigate the text is beautiful. Maybe could get some tips from just watching you code.

  • @codebulls7943
    @codebulls7943 Рік тому

    You are a beast sir

  • @DivjotSingh
    @DivjotSingh Рік тому

    Reassigning entries just kinda broke my mind. Of course you should be able to do it, the entries would be reassigned when the data from the backend comes anyway, but somehow the push to always use const made it unintuitive for me.

    • @samselikoff
      @samselikoff  Рік тому +2

      I think const is overused :) Local reassignment is extremely handy (and safe) in JS!

  • @amirnoorani5017
    @amirnoorani5017 Рік тому +2

    Sam could you make a video about Why remix? I saw in some of your videos you use remix. Is it better than Next.js?

    • @samselikoff
      @samselikoff  Рік тому +6

      Good idea! Remix feels more stable to me at the moment, but I really like both frameworks. I'm really excited about Server Components + Server Actions in Next.js, but the current caching defaults feel complicated. Maybe I will make a video talking about it!

    • @amirnoorani5017
      @amirnoorani5017 Рік тому

      @@samselikoff thanks. That would be great because there is little information on Remix

  • @eleah2665
    @eleah2665 Рік тому

    A lot going on there. Remix = good.

  • @samiullahsheikh5015
    @samiullahsheikh5015 7 місяців тому

    How to revert back if data failed to save in database?

  • @muhammadbinjamil9998
    @muhammadbinjamil9998 Рік тому +2

    How do you handle optimistic UI in case of a failure, say a network error?

    • @samselikoff
      @samselikoff  Рік тому +1

      Was thinking of making a follow-up if enough folks asked this - sounds like it might be worth it!

  • @SinhNguyen-tz6us
    @SinhNguyen-tz6us Рік тому

    Hi Sam, great video as usual. I have some quetions:
    - How will you do optimistic UI when there is error? (like network error or 4xx error when POST)
    - Instead of optimistic UI, what If I want to show a toast to inform the user, how will you do it? Currently I'm thinking of using the session but it seem too much for me.
    Thanks in advanced.

    • @samselikoff
      @samselikoff  Рік тому +2

      I think I'll have to make a follow-up to show how to do error handling since plenty of folks are interested in it!
      For the Toast I would use Radix Toast (or one of the other headless UI libraries), I actually just shared a code demo for one here: buildui.com/recipes/animated-toast. You'd need to call the showToast method whenever you want one to show up. Shouldn't need the session. In your example, when do you a toast to show up? After each item is saved, or after all pending items are saved?

    • @SinhNguyen-tz6us
      @SinhNguyen-tz6us Рік тому

      @@samselikoff wow, thanks for your reply. In my example, I want to show the toast after each item is saved.

    • @samselikoff
      @samselikoff  Рік тому +1

      @@SinhNguyen-tz6us You're welcome! In that case you should be able to just call the `showToast()` method from the recipe I linked to after you call `submit()` on the form! You can also use a library like React Hot Toast if you don't need as much control over styling/position/animation.

    • @SinhNguyen-tz6us
      @SinhNguyen-tz6us Рік тому

      @@samselikoff Thank you, again.

  • @udaym4204
    @udaym4204 10 місяців тому

    remix vs next js what is diffrent

  • @volumepunch
    @volumepunch Рік тому +1

    What happens if the server returns an error? Will the item stays in the list or will it be removed?

    • @samselikoff
      @samselikoff  Рік тому

      I think I'll make a quick follow-up to address it!

  • @shadowfaxenator
    @shadowfaxenator Рік тому

    What's about redirect from action? Otherwise if you click back button you'll post again. And especially if no JS you should redirect to revalidate

  • @gamehelp16
    @gamehelp16 Рік тому +1

    Are there any security concerns by letting the client side determine the id of the entries?

    • @samselikoff
      @samselikoff  Рік тому +4

      Nope, assuming your backend (1) has standard validation logic against creating records with duplicate IDs (uniqueness constraint on the database), and (2) doesn't expose any sensitive information based on the client knowing a record's ID (which is typically covered by auth logic in loaders/actions already, since exposing resource IDs is a common way to build web apps)!

    • @KenMarfilla
      @KenMarfilla Рік тому +1

      The reason ID is needed in the video is because it is needed to render the edit link. If you make the edit link render conditionally, you don't need to ID in advance. The revalidation will take care of eventually producing the ID.

    • @gamehelp16
      @gamehelp16 Рік тому

      @@samselikoff Do you have any tips on how to handle if a collision in the ID were to ever happen?

    • @samjohnston3416
      @samjohnston3416 Рік тому

      ⁠@@gamehelp16with UUIDs this has a VERY slim case of happening were talking 2+ quintillion records for it to even have a chance of happening (according to Wikipedia)

  • @jon1867
    @jon1867 11 місяців тому +1

    I have to say, I find doing optimistic UI in remix not that fun for more complex stuff than this. It feels like trying to shave down a square peg to fit in a round hole.

  • @codewithnws3544
    @codewithnws3544 11 місяців тому

    Can you give us the code link, repo to this project!

  • @predaytor
    @predaytor Рік тому

    What's that vscode theme? Looks like a bit darker Dracula theme😯
    Thx.

    • @samselikoff
      @samselikoff  Рік тому +2

      Yep, Dracula with a few tweaks to match slate-900 from Tailwind. Just threw it up in a gist: gist.github.com/samselikoff/7a79b5363f87b838b88025ba992835c5

    • @predaytor
      @predaytor Рік тому

      @@samselikoff❤

  • @oscarljimenez5717
    @oscarljimenez5717 Рік тому

    Great video, but i still don't understand why people use let over const 😐

    • @samselikoff
      @samselikoff  Рік тому +1

      fewer characters to type :P
      also overreacted.io/on-let-vs-const/
      but really I could care less, I might switch to const soon just so it's not a distraction

    • @baldcoder_
      @baldcoder_ Рік тому

      Is this debate still a thing? It doesn't matter what you use as long as you're not using var.

  • @drewhjava
    @drewhjava Рік тому

    Serious question, is it tough for you to give tutorials for things that Ember could do 40 years ago? I'm digging Remix over Next for sure.

    • @samselikoff
      @samselikoff  11 місяців тому

      Haha there are def some places where Remix is still catching up but overall I'm liking working with lower-level tools these days

  • @polyander
    @polyander Рік тому

    please more next.js & framer motion

    • @samselikoff
      @samselikoff  Рік тому +1

      👍 what framer motion stuff do you want to see?