Optimistic Updates In React - The Best Way

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
    @codinginflow12 күн бұрын

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

  • @sobrehombre9338
    @sobrehombre933812 күн бұрын

    Interesting. Thanks!

  • @Masthuhn7
    @Masthuhn712 күн бұрын

    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

    12 күн бұрын

    Usually people upload files to a storage bucket like S3

  • @abdellahalaoui6609
    @abdellahalaoui660912 күн бұрын

    How about react-query?

  • @codinginflow

    @codinginflow

    12 күн бұрын

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

  • @Jibs-iq1em

    @Jibs-iq1em

    12 күн бұрын

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

  • @CharcoalDaddyBBQ

    @CharcoalDaddyBBQ

    12 күн бұрын

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

  • @kasper369
    @kasper36912 күн бұрын

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

  • @codinginflow

    @codinginflow

    11 күн бұрын

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

  • @olteanumihai1245
    @olteanumihai124512 күн бұрын

    or you can use state mgmt :)

  • @codinginflow

    @codinginflow

    12 күн бұрын

    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

    11 күн бұрын

    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

    10 күн бұрын

    @@imakhlaqXD Caching, revaliation, race conditions

  • @raves_r3177
    @raves_r317711 күн бұрын

    why not react query

  • @codinginflow

    @codinginflow

    11 күн бұрын

    That's fine too