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
Get my FREE React Best Practices course: codinginflow.com/reactbestpractices
Interesting. Thanks!
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.
Usually people upload files to a storage bucket like S3
How about react-query?
Probably even better than SWR, but I have never used it
was about to ask the same, I used react query for something similar and it came through 😊
Love react query. Very clean and easy to read when checking bugs. Has all these features above.
Quick question will using SWR increase backend api calls ? Wont that be bad
Yes, revalidation requires API calls. You can disable it if you don't like it.
or you can use state mgmt :)
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.
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??
@@imakhlaqXD Caching, revaliation, race conditions
why not react query
That's fine too