Optimistic Updates In React - The Best Way

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 มิ.ย. 2024
  • How I handle optimistic updates in my React.js app and why I dislike the new useOptimistic hook.
    ⭐ Get my full-stack Next.js with Express & TypeScript course: codinginflow.com/nextjs
    ✅ Get my free React Best Practices course: www.codinginflow.com/reactbes...
    💌 Join my newsletter for regular web dev tips: codinginflow.com/newsletter
    💬 Join our developer community on Discord: codinginflow.com/discord
    📣 Follow Coding in Flow on social media:
    Twitter: / codinginflow
    Instagram: / codinginflow
    TikTok: / codinginflow
    Facebook: / codinginflow

ความคิดเห็น • 16

  • @codinginflow
    @codinginflow  9 วันที่ผ่านมา

    Get my FREE React Best Practices course: codinginflow.com/reactbestpractices

  • @sobrehombre9338
    @sobrehombre9338 9 วันที่ผ่านมา +1

    Interesting. Thanks!

  • @Masthuhn7
    @Masthuhn7 9 วันที่ผ่านมา

    Hi, I have a problem in Next.js.
    When users upload images and they are saved in /public/uploads, they are only accessible after running npm run build & npm start again. To solve this problem, you could set up a separate Express server that only handles uploads. A video tutorial on this would be great, as I have seen many people not knowing the best way to solve this issue.
    Thanks and best regards.

    • @codinginflow
      @codinginflow  9 วันที่ผ่านมา +2

      Usually people upload files to a storage bucket like S3

  • @abdellahalaoui6609
    @abdellahalaoui6609 9 วันที่ผ่านมา +3

    How about react-query?

    • @codinginflow
      @codinginflow  9 วันที่ผ่านมา +3

      Probably even better than SWR, but I have never used it

    • @Jibs-iq1em
      @Jibs-iq1em 9 วันที่ผ่านมา

      was about to ask the same, I used react query for something similar and it came through 😊

    • @CharcoalDaddyBBQ
      @CharcoalDaddyBBQ 8 วันที่ผ่านมา

      Love react query. Very clean and easy to read when checking bugs. Has all these features above.

  • @kasper369
    @kasper369 9 วันที่ผ่านมา

    Quick question will using SWR increase backend api calls ? Wont that be bad

    • @codinginflow
      @codinginflow  8 วันที่ผ่านมา

      Yes, revalidation requires API calls. You can disable it if you don't like it.

  • @olteanumihai1245
    @olteanumihai1245 9 วันที่ผ่านมา +1

    or you can use state mgmt :)

    • @codinginflow
      @codinginflow  9 วันที่ผ่านมา +1

      I'm not sure if that's the right solution here because this is remote state, not app state. SWR handles remote state for you.

    • @imakhlaqXD
      @imakhlaqXD 7 วันที่ผ่านมา

      Soo if its remote so why are we not using simple state and when doing request we update the state and if somethings goes wrong then reset the update ???. Am i missing something??

    • @codinginflow
      @codinginflow  7 วันที่ผ่านมา

      @@imakhlaqXD Caching, revaliation, race conditions

  • @raves_r3177
    @raves_r3177 8 วันที่ผ่านมา

    why not react query

    • @codinginflow
      @codinginflow  8 วันที่ผ่านมา

      That's fine too