diff --git a/ui/src/Components/LabelSetList/index.js b/ui/src/Components/LabelSetList/index.js index 4aebf4276..e8eb7aeda 100644 --- a/ui/src/Components/LabelSetList/index.js +++ b/ui/src/Components/LabelSetList/index.js @@ -1,8 +1,7 @@ -import React, { Component } from "react"; +import React from "react"; import PropTypes from "prop-types"; -import { observer } from "mobx-react"; -import { observable, action } from "mobx"; +import { useLocalStore, useObserver } from "mobx-react"; import hash from "object-hash"; @@ -29,70 +28,60 @@ const GroupListToUniqueLabelsList = (groups) => { return Object.values(alerts); }; -const LabelSetList = observer( - class LabelSetList extends Component { - static propTypes = { - alertStore: PropTypes.instanceOf(AlertStore).isRequired, - labelsList: PropTypes.arrayOf(PropTypes.object).isRequired, - }; +const LabelSetList = ({ alertStore, labelsList }) => { + const pagination = useLocalStore(() => ({ + activePage: 1, + onPageChange(pageNumber) { + pagination.activePage = pageNumber; + }, + })); - maxPerPage = 10; + const maxPerPage = 10; - pagination = observable( - { - activePage: 1, - onPageChange(pageNumber) { - this.activePage = pageNumber; - }, - }, - { - onPageChange: action.bound, - } - ); - - render() { - const { alertStore, labelsList } = this.props; - - return labelsList.length > 0 ? ( + return useObserver(() => + labelsList.length > 0 ? ( +
Affected alerts
Affected alerts
-No alerts matched
- ); - } - } -); +No alerts matched
+ ) + ); +}; +LabelSetList.propTypes = { + alertStore: PropTypes.instanceOf(AlertStore).isRequired, + labelsList: PropTypes.arrayOf(PropTypes.object).isRequired, +}; export { LabelSetList, GroupListToUniqueLabelsList };