Lifecycle.js 445 B

123456789101112131415161718192021
  1. import React from "react";
  2. class Lifecycle extends React.Component {
  3. componentDidMount() {
  4. if (this.props.onMount) this.props.onMount.call(this, this);
  5. }
  6. componentDidUpdate(prevProps) {
  7. if (this.props.onUpdate) this.props.onUpdate.call(this, this, prevProps);
  8. }
  9. componentWillUnmount() {
  10. if (this.props.onUnmount) this.props.onUnmount.call(this, this);
  11. }
  12. render() {
  13. return null;
  14. }
  15. }
  16. export default Lifecycle;