From 71daaf6021da270ecc245d2b81206b53139e0fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Flatval?= Date: Mon, 31 Jul 2023 10:01:27 +0200 Subject: [PATCH] chore: lint fix --- react-components/src/components/InfoCard/InfoCard.tsx | 10 ++++++---- .../RevealContainer/AuxillaryDivProvider.tsx | 10 +--------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/react-components/src/components/InfoCard/InfoCard.tsx b/react-components/src/components/InfoCard/InfoCard.tsx index 41df376ce45..ba008200742 100644 --- a/react-components/src/components/InfoCard/InfoCard.tsx +++ b/react-components/src/components/InfoCard/InfoCard.tsx @@ -2,7 +2,7 @@ * Copyright 2023 Cognite AS */ -import React, { type JSX, useState, useEffect, useRef } from 'react'; +import React, { type JSX, useEffect, useRef } from 'react'; import { type Vector3 } from 'three'; import { useReveal } from '../RevealContainer/RevealContext'; @@ -24,7 +24,7 @@ export type InfoCardProps = { export const InfoCard = ({ position, children, uniqueKey }: InfoCardProps): JSX.Element => { const viewer = useReveal(); - const [htmlTool, _setHtmlTool] = useState(new HtmlOverlayTool(viewer)); + const htmlTool = useRef(new HtmlOverlayTool(viewer)); const auxContext = useAuxillaryDivContext(); @@ -49,9 +49,11 @@ export const InfoCard = ({ position, children, uniqueKey }: InfoCardProps): JSX. const elementRef = htmlRef.current; - htmlTool.add(elementRef, position); + htmlTool.current.add(elementRef, position); - return () => htmlTool.remove(elementRef); + return () => { + htmlTool.current.remove(elementRef); + }; }, [auxContext, children, htmlRef.current]); return <>; diff --git a/react-components/src/components/RevealContainer/AuxillaryDivProvider.tsx b/react-components/src/components/RevealContainer/AuxillaryDivProvider.tsx index 1d630513297..e21c0c92808 100644 --- a/react-components/src/components/RevealContainer/AuxillaryDivProvider.tsx +++ b/react-components/src/components/RevealContainer/AuxillaryDivProvider.tsx @@ -2,15 +2,7 @@ * Copyright 2023 Cognite AS */ -import { HtmlOverlayTool } from '@cognite/reveal/tools'; -import React, { - createContext, - useContext, - useState, - useCallback, - useEffect, - type JSX -} from 'react'; +import React, { createContext, useContext, useState, useCallback, type JSX } from 'react'; export const AuxillaryDivProvider = ({ children }: { children: React.ReactNode }): JSX.Element => { const [elements, setElements] = useState([]);