From 70f431f0db7d6c8af30b4d35c0f360864e708d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Thu, 16 Apr 2020 17:55:30 +0100 Subject: [PATCH] fix(ui): rewrite FetchPauser using hooks --- ui/src/Components/FetchPauser/index.js | 30 ++++++++++---------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/ui/src/Components/FetchPauser/index.js b/ui/src/Components/FetchPauser/index.js index e5ecce310..464648d57 100644 --- a/ui/src/Components/FetchPauser/index.js +++ b/ui/src/Components/FetchPauser/index.js @@ -1,27 +1,19 @@ -import { Component } from "react"; +import { useEffect } from "react"; import PropTypes from "prop-types"; import { AlertStore } from "Stores/AlertStore"; -class FetchPauser extends Component { - static propTypes = { - children: PropTypes.any, - alertStore: PropTypes.instanceOf(AlertStore).isRequired, - }; - - componentDidMount() { - const { alertStore } = this.props; +const FetchPauser = ({ children, alertStore }) => { + useEffect(() => { alertStore.status.pause(); - } + return alertStore.status.resume; + }, [alertStore.status]); - componentWillUnmount() { - const { alertStore } = this.props; - alertStore.status.resume(); - } - - render() { - return this.props.children; - } -} + return children; +}; +FetchPauser.propTypes = { + children: PropTypes.any, + alertStore: PropTypes.instanceOf(AlertStore).isRequired, +}; export { FetchPauser };