Tag

useRef

0 views collected around this technical thread.

Code Mala Tang
Code Mala Tang
Jul 5, 2024 · Frontend Development

Mastering React refs: When and How to Use forwardRef, useRef, and useImperativeHandle

This article explains how React refs work with native elements, class components, and function components, demonstrates using useRef, forwardRef, and useImperativeHandle, and discusses the benefits, drawbacks, and alternative patterns for exposing component instances and DOM nodes.

ReactforwardReffrontend
0 likes · 10 min read
Mastering React refs: When and How to Use forwardRef, useRef, and useImperativeHandle
Tencent IMWeb Frontend Team
Tencent IMWeb Frontend Team
Jun 3, 2021 · Frontend Development

Understanding Capture Value in React Hooks: Why State Updates Lag and How to Fix Them

This article explains the concept of Capture Value in React Hooks, demonstrates the issue with asynchronous state updates using a button example, and shows how to resolve it with useRef, while also providing a simplified custom hook implementation and deeper insight into hook internals.

Capture ValueFrontend DevelopmentReact
0 likes · 6 min read
Understanding Capture Value in React Hooks: Why State Updates Lag and How to Fix Them