Nextjs actions in 0 milliseconds

Опубликовано: 30 Июль 2024
на канале: Dev Leonardo
634
22

What if you could make your backend respond in 0ms? ⚡️

In a real scenario, some api calls will most often be successful (hopefully) so here's the trick, bring some optimism in your application and instantly update the UI as if the operation went through.

You can't have a slow backend, if you don't even wait for the response 🧠

I tested the useOptimistic hook introduced in React 18 in my new Nextjs 14 side project and I thought it was worth sharing!
_______________________________
Support my work: https://github.com/sponsors/Balastrong ❤️

Hit like and subscribe for more content! :D

Beginner-Friendly Open Source Projects: https://github.com/DevLeonardoCommunity
Join the Discord community! Here's the invite:   / discord  

You can also follow me on the other platforms:
Twitter:   / balastrong  
dev.to: https://dev.to/balastrong
GitHub: https://github.com/Balastrong
Home: https://leonardomontini.dev/
TikTok:   / balastrong  
Instagram:   / devbalastrong  

_______________________________
TIMESTAMPS
00:00 Problem Showcase
01:00 Simple Optimistic Update
02:00 Optimistic Array Element Removal
04:40 Updates Outside Server Actions
05:24 Optimistic Double Render
06:00 Optimistic Reducer
08:12 Bonus Tip
08:38 Code on GitHub - Myntenance Project

#nextjs #coding #reactjs


На этой странице сайта вы можете посмотреть видео онлайн Nextjs actions in 0 milliseconds длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Dev Leonardo 30 Июль 2024, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 634 раз и оно понравилось 22 зрителям. Приятного просмотра!