What happens during the "Unmounting" phase of a React Native component's life cycle?

4 phương ánCó giải thích

Các phương án trả lời

Chọn một phương án
Lời giảiChọn phương án để mở
Đáp án đúng: "The component is removed from the DOM.". Unmounting là giai đoạn cuối của vòng đời: component bị gỡ khỏi cây giao diện (trong React Native là cây view native, chữ DOM ở đây dùng theo cách gọi quen thuộc của React web); ngay trước đó componentWillUnmount hoặc hàm cleanup của useEffect chạy để huỷ timer, listener, subscription, tránh rò rỉ bộ nhớ. "The component is created and rendered in the DOM." là giai đoạn Mounting, khi constructor, render và componentDidMount chạy lần đầu. "The component is updated with new state or props." là giai đoạn Updating, xảy ra mỗi khi dữ liệu thay đổi. "The component handles errors." là giai đoạn Error Handling, dùng getDerivedStateFromError và componentDidCatch trong error boundary.

Cùng chương 2

Xuất hiện trong 1 bộ đề