Nâng CaoReact iconReact

useImperativeHandle hook dùng để làm gì?

useImperativeHandle kết hợp với forwardRef để tùy chỉnh những gì parent nhìn thấy qua ref, thay vì expose toàn bộ DOM node.

Ví dụ: expose chỉ focus()scrollIntoView() thay vì toàn bộ input element. Giúp đóng gói internal implementation, chỉ expose API cần thiết. Dùng khi cần imperative API từ component.

Xem toàn bộ React cùng filter theo level & chủ đề con.

Mở danh sách React