Тёмный

Is useReducer Really Better Than useState? 

Ljupche Vasilev
Подписаться 864
Просмотров 290
50% 1

Desk setup:
💻 Macbook Air M2 8GB RAM, 512GB SSD: (US) amzn.to/4ckunuo | (UK) amzn.to/3PrjddH
⌨️ Apple Magic Keyboard: (US) amzn.to/3IGam3J | (UK) amzn.to/3TetzOQ
🖱️ Apple Magic Mouse: (US) amzn.to/3J1Juf3 | (UK) amzn.to/48YZvfZ
📱 Laptop stand: (US) amzn.to/49X0Ghu | (UK) amzn.to/3wZYwPy
🖥️ Dell 27 inch Full HD Monitor: (US) amzn.to/3TFj0FX | (UK) amzn.to/49ZaIi4
🔲 Dual Monitor Stand: (US) amzn.to/3vr0MyG | (UK) amzn.to/48XxRjK
🎧 Beats Studio Pro: (US) amzn.to/3Tj3yy9 | (UK) amzn.to/3ViiaAr
💡 Notion software project template: affiliate.notion.so/lv-softwa...
If you’ve dealt with global state management in React, you’ve likely come across reducers. When I first explored implementing global state without Redux, I found useReducer confusing. However, useReducer can replace multiple useState calls, making your code cleaner and more flexible. Before React’s context and useReducer hooks, we used Redux, which involves a store, actions, and reducers to manage state. useReducer, an advanced useState, accepts a reducer function and initial state, allowing parameterized dispatches. Combining useReducer with React context is a powerful approach for state management.
Stay tuned for more coding tips and tutorials. Happy coding, and I'll catch you in the next one! 🌟🚀👨‍💻
Background song by:
/ dahjp

Опубликовано:

 

8 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 2   
@leo_and_his_bikes
@leo_and_his_bikes Месяц назад
Nice recommendation. I think useReducer can be a nice option to delegate some of the logic from the component while avoiding overusing redux or context for some state management only occurring in one component.
@LjupcheVasilev
@LjupcheVasilev Месяц назад
Yeah, great point, delegating logic is definitely another one of the advantages of reducers
Далее
Do This Instead Of Loading Skeletons
13:30
Просмотров 564
State Managers Are Making Your Code Worse In React
13:33
Дьявол - ТРЕШ ОБЗОР на фильм
19:10
100+ Linux Things you Need to Know
12:23
Просмотров 772 тыс.
What Are ORMs and Why Is Prisma Falling Behind
13:15
Просмотров 1,8 тыс.
Brutally honest advice for new .NET Web Developers
7:19
These 2 UI Libraries Are The Perfect Combo
5:03
Просмотров 127 тыс.
You Don't Have to Delete Things Permanently
14:32
Просмотров 1 тыс.
Don't use VSCode
35:31
Просмотров 214 тыс.
My Top 5 React Libraries for 2023
5:12
Просмотров 39 тыс.