import React, { useEffect, useRef, useState, memo } from "react"; import PropTypes from "prop-types"; import Linkify from "react-linkify"; import Flash from "react-reveal/Flash"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons/faExternalLinkAlt"; import { faSearchPlus } from "@fortawesome/free-solid-svg-icons/faSearchPlus"; import { faSearchMinus } from "@fortawesome/free-solid-svg-icons/faSearchMinus"; import { TooltipWrapper } from "Components/TooltipWrapper"; const RenderNonLinkAnnotation = memo( ({ name, value, visible, afterUpdate }) => { const mountRef = useRef(false); const [isVisible, setIsVisible] = useState(visible); useEffect(() => { if (mountRef.current) { afterUpdate(); } else { mountRef.current = true; } }); const className = "mb-1 p-1 bg-light d-inline-block rounded components-grid-annotation text-break mw-100"; if (!isVisible) { return (
setIsVisible(!isVisible)} > {name}
); } return (
setIsVisible(false)} className="cursor-pointer"> {name}: {value}
); } ); RenderNonLinkAnnotation.propTypes = { name: PropTypes.string.isRequired, value: PropTypes.string.isRequired, visible: PropTypes.bool.isRequired, afterUpdate: PropTypes.func.isRequired, }; const RenderLinkAnnotation = ({ name, value }) => { return ( {name} ); }; RenderLinkAnnotation.propTypes = { name: PropTypes.string.isRequired, value: PropTypes.string.isRequired, }; export { RenderNonLinkAnnotation, RenderLinkAnnotation };