State Management with Jotai: Hydrate Atom with Server-side Initial State

  Рет қаралды 2,816

makrdev

makrdev

Күн бұрын

In this video we will explore how we can use Jotai's "useHydrateAtoms" hook to hydrate our atoms with the server-side data. This method helps us avoid prop-drilling as well as unnecassary re-renders in our application.
After we finish implementing "useHydrateAtoms", we will focus on two utilities from Jotai: "focusAtom" and "selectAtom" These utilities will help us avoid re-rendering the components that we don't update.
I hope that you like this video and if you do, please don't forget to subscribe my channel and if you have any question please leave it as a comment!
- timestamps -
00:00 - Intro
01:09 - useState version
03:50 - useHydrateAtom
07:55 - Prop Drilling
19:00 - selectAtom
24:40 - focusAtom
29:11 - Further Optimisation
31:33 - Outro
Source Code: github.com/batuhanbilginn/jot...
Learn more: makr.dev
#react #statemanagement #nextjs #jotai

Пікірлер: 9
@xolanimethula8472
@xolanimethula8472 6 ай бұрын
Valuable video, Please try to zoom in on your next tutorial.
@enesdemirci7963
@enesdemirci7963 Жыл бұрын
Hocam simdi nextjs13 ile bi blog yapiyorum state manager olarakda jotai kullaniyorum , dark light mode yaptim true false degeri degisiyor ama sayfa refresh olmadan renk degisimi olmiyor , hydretaiton kullanmam mi gerekiyor nasil cozebilirim
@makrdev
@makrdev Жыл бұрын
discord.gg/hxhaxFYk gel buradan konuşalım daha kolay olur.
@shinauri1
@shinauri1 6 ай бұрын
Great video sir. But I have question: is it a good idea to completely abandon props and tie every component to Jotai? How then to reuse such components?
@makrdev
@makrdev 6 ай бұрын
This is not applicable for every component. If you need to reuse the component you can create an atom and pass as prop to consume in the component or you can create more advanced logic such as atom families etc. in order to create reusable state logic. If you can avoid using props and it doesn’t break your logic yes it’s a good thing otherwise build what you need.
@lokifurian
@lokifurian Жыл бұрын
But since it's a client component, the state is undefined on the server until on the client right?
@makrdev
@makrdev Жыл бұрын
Yeah it handles suspense and other things. I’m not sure how it works with RSC tho.
@lokifurian
@lokifurian Жыл бұрын
@@makrdev yeah because if I log, the terminal which is server side logs undefined. 🤨 There does not seem a way to fill the initial data server side in a server component unless i am missing something? This is using the next js app directory btw.
@makrdev
@makrdev Жыл бұрын
Join discord I can help you in there.
Mastering React Context: Do you NEED a state manager?
37:26
Jack Herrington
Рет қаралды 98 М.
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 114 МЛН
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 36 МЛН
Can A Seed Grow In Your Nose? 🤔
00:33
Zack D. Films
Рет қаралды 24 МЛН
Do you REALLY need SSR?
18:15
Theo - t3․gg
Рет қаралды 165 М.
State Managers Are Making Your Code Worse In React
13:33
Web Dev Simplified
Рет қаралды 171 М.
How to create background jobs with Next.js and Inngest
23:33
makrdev
Рет қаралды 3,3 М.
Rebuilding Jotai State Manager for React in 20 Minutes!
20:25
Jack Herrington
Рет қаралды 31 М.
Turbocharge React Shopping Cart: Jotai State Management!
38:07
Mafia Codes
Рет қаралды 2,3 М.
What is my favorite React state management library
29:17
Web Dev Cody
Рет қаралды 11 М.
When RESTful architecture isn't enough...
21:02
Dreams of Code
Рет қаралды 264 М.
"The Life & Death of htmx" by Alexander Petros at Big Sky Dev Con 2024
23:01
Montana Programmers
Рет қаралды 42 М.
Частая ошибка геймеров? 😐 Dareu A710X
1:00
Вэйми
Рет қаралды 4,6 МЛН
İĞNE İLE TELEFON TEMİZLEMEK!🤯
0:17
Safak Novruz
Рет қаралды 1,9 МЛН
Vision Pro наконец-то доработали! Но не Apple!
0:40
ÉЖИ АКСЁНОВ
Рет қаралды 88 М.
ноутбуки от 7.900 в тг laptopshoptop
0:14
Ноутбуковая лавка
Рет қаралды 3,4 МЛН