Tag

useReducer

1 views collected around this technical thread.

Code Mala Tang
Code Mala Tang
Mar 19, 2025 · Frontend Development

When useState Becomes a Trap: Why useReducer Is the Better Choice

This article explains why overusing useState in complex React components can lead to tangled code and bugs, and demonstrates how switching to useReducer provides a single source of truth, clearer actions, and more maintainable state management.

Hooksfrontendreact
0 likes · 12 min read
When useState Becomes a Trap: Why useReducer Is the Better Choice
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Oct 17, 2023 · Frontend Development

Comprehensive React Query Tutorial: Managing Server and Client State in React

This tutorial introduces React Query (TanStack Query), explains its motivation, demonstrates how to manage client and server state in React using hooks, Context, useReducer, and provides best practices for caching, optimistic updates, reducing duplicate requests, and performance optimization techniques.

Context APIReact QueryTanStack Query
0 likes · 17 min read
Comprehensive React Query Tutorial: Managing Server and Client State in React
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Feb 13, 2023 · Frontend Development

Advanced Tips and Common Pitfalls for React Hooks (useState, useEffect, useContext, useReducer, etc.)

This article provides in‑depth guidance on using React hooks such as useState, useEffect, useContext, useReducer, and related utilities, covering lazy initialization, functional updates, performance‑optimising patterns, state sharing strategies, and advanced techniques like useImmer and react‑tracked to reduce mental overhead and avoid bugs.

HooksPerformancereact
0 likes · 16 min read
Advanced Tips and Common Pitfalls for React Hooks (useState, useEffect, useContext, useReducer, etc.)
DaTaobao Tech
DaTaobao Tech
Aug 17, 2022 · Frontend Development

Understanding and Using the useReducer Hook in React

React’s useReducer hook, introduced in version 16.8, lets a component manage complex state by supplying a reducer function and an initial value, returning [state, dispatch] where dispatch triggers actions; it supports lazy initialization, centralizes updates, works with useContext for shared state, and is preferable to useState for non‑trivial logic but less suited than full Redux for large‑scale state needs.

HooksJavaScriptreact
0 likes · 19 min read
Understanding and Using the useReducer Hook in React