diff --git a/ui/src/Components/Grid/AlertGrid/AlertGroup/Annotation/index.js b/ui/src/Components/Grid/AlertGrid/AlertGroup/Annotation/index.js index fbf0b57d2..6e74ee8f1 100644 --- a/ui/src/Components/Grid/AlertGrid/AlertGroup/Annotation/index.js +++ b/ui/src/Components/Grid/AlertGrid/AlertGroup/Annotation/index.js @@ -1,8 +1,6 @@ -import React, { useEffect, useRef } from "react"; +import React, { useEffect, useRef, useState, memo } from "react"; import PropTypes from "prop-types"; -import { useLocalStore, observer } from "mobx-react"; - import Linkify from "react-linkify"; import Flash from "react-reveal/Flash"; @@ -14,10 +12,12 @@ import { faSearchMinus } from "@fortawesome/free-solid-svg-icons/faSearchMinus"; import { TooltipWrapper } from "Components/TooltipWrapper"; -const RenderNonLinkAnnotation = observer( +const RenderNonLinkAnnotation = memo( ({ name, value, visible, afterUpdate }) => { const mountRef = useRef(false); + const [isVisible, setIsVisible] = useState(visible); + useEffect(() => { if (mountRef.current) { afterUpdate(); @@ -26,23 +26,16 @@ const RenderNonLinkAnnotation = observer( } }); - const toggle = useLocalStore(() => ({ - visible: visible, - show(e) { - this.visible = true; - }, - hide(e) { - this.visible = false; - }, - })); - const className = "mb-1 p-1 bg-light d-inline-block rounded components-grid-annotation text-break mw-100"; - if (!toggle.visible) { + if (!isVisible) { return ( -
+
setIsVisible(!isVisible)} + > {name}
@@ -53,7 +46,7 @@ const RenderNonLinkAnnotation = observer( return (
- + setIsVisible(false)} className="cursor-pointer"> {name}: