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 ánLờ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
A View component can be nested inside other views. Select the correct option.Có lời giảiCâu hỏiWhich component is the foundation for all React Native components and provides the base functionality for rendering elements to the screen?Có lời giảiCâu hỏiWhich keyword is used to extend a component from a base component?Có lời giảiCâu hỏiCả 54 câu của chủ đề54 câu