Trung BìnhReact iconReact

Thứ tự lifecycle methods khi component mount, update, unmount là gì?

Thứ tự lifecycle methods qua 3 giai đoạn:

  • Mount: constructor → getDerivedStateFromProps → render → DOM update → componentDidMount.
  • Update: getDerivedStateFromProps → shouldComponentUpdate → render → getSnapshotBeforeUpdate → DOM update → componentDidUpdate.
  • Unmount: componentWillUnmount → component bị xóa.
  • Với concurrent mode, render phase có thể bị interrupt.

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

Mở danh sách React