diff --git a/ui/packages/shared/profile/src/MatchersInput/index.tsx b/ui/packages/shared/profile/src/MatchersInput/index.tsx
index 9b763e13de4..ead486d853c 100644
--- a/ui/packages/shared/profile/src/MatchersInput/index.tsx
+++ b/ui/packages/shared/profile/src/MatchersInput/index.tsx
@@ -211,7 +211,7 @@ const MatchersInput = ({setDraftMatchers, draftParsedQuery, commitDraft}: Props)
isLabelNamesLoading={isLabelNamesLoading}
suggestions={suggestionSections}
applySuggestion={applySuggestion}
- inputRef={inputRef.current}
+ inputRef={inputRef}
runQuery={commitDraft}
focusedInput={focusedInput}
isLabelValuesLoading={
diff --git a/ui/packages/shared/profile/src/MetricsGraph/MetricsTooltip/index.tsx b/ui/packages/shared/profile/src/MetricsGraph/MetricsTooltip/index.tsx
index 921719e66ad..876f6eb5c06 100644
--- a/ui/packages/shared/profile/src/MetricsGraph/MetricsTooltip/index.tsx
+++ b/ui/packages/shared/profile/src/MetricsGraph/MetricsTooltip/index.tsx
@@ -11,7 +11,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-import {useEffect, useMemo, useState} from 'react';
+/* eslint-disable react-hooks/refs */
+
+import {useLayoutEffect, useRef, useState} from 'react';
import {usePopper} from 'react-popper';
@@ -28,21 +30,16 @@ interface Props {
content: React.ReactNode;
}
-const virtualElement: VirtualElement = {
- getBoundingClientRect: () => {
- const emptyRect: DOMRect = {
- width: 0,
- height: 0,
- top: 0,
- right: 0,
- bottom: 0,
- left: 0,
- x: 0,
- y: 0,
- toJSON: () => ({}),
- };
- return emptyRect;
- },
+const emptyRect: DOMRect = {
+ width: 0,
+ height: 0,
+ top: 0,
+ right: 0,
+ bottom: 0,
+ left: 0,
+ x: 0,
+ y: 0,
+ toJSON: () => ({}),
};
const createDomRect = (x: number, y: number): DOMRect => {
@@ -61,9 +58,13 @@ const createDomRect = (x: number, y: number): DOMRect => {
};
const MetricsTooltip = ({x, y, contextElement, content}: Props): JSX.Element => {
+ 'use no memo';
const [popperElement, setPopperElement] = useState
(null);
+ const virtualElementRef = useRef({
+ getBoundingClientRect: () => emptyRect,
+ });
- const {styles, attributes, update} = usePopper(virtualElement, popperElement, {
+ const {styles, attributes, update} = usePopper(virtualElementRef.current, popperElement, {
placement: 'auto-start',
strategy: 'absolute',
modifiers: [
@@ -82,26 +83,13 @@ const MetricsTooltip = ({x, y, contextElement, content}: Props): JSX.Element =>
],
});
- useMemo(() => {
- virtualElement.getBoundingClientRect = (): DOMRect => {
- const domRect: DOMRect = (contextElement as Element)?.getBoundingClientRect() ?? {
- width: 0,
- height: 0,
- top: 0,
- right: 0,
- bottom: 0,
- left: 0,
- x: 0,
- y: 0,
- toJSON: () => ({}),
- };
+ useLayoutEffect(() => {
+ virtualElementRef.current.getBoundingClientRect = (): DOMRect => {
+ const domRect: DOMRect = (contextElement as Element)?.getBoundingClientRect() ?? emptyRect;
return createDomRect(domRect.x + x, domRect.y + y);
};
- }, [x, y, contextElement]);
-
- useEffect(() => {
void update?.();
- }, [x, y, update]);
+ }, [x, y, contextElement, update]);
// Don't render anything if content is null or undefined
if (content == null) {
diff --git a/ui/packages/shared/profile/src/PreSelectedMatchers/index.tsx b/ui/packages/shared/profile/src/PreSelectedMatchers/index.tsx
index eb3d66ac0fd..74eabd153b9 100644
--- a/ui/packages/shared/profile/src/PreSelectedMatchers/index.tsx
+++ b/ui/packages/shared/profile/src/PreSelectedMatchers/index.tsx
@@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+/* eslint-disable react-hooks/refs */
+
import React, {useCallback, useEffect, useRef, useState} from 'react';
import {Icon} from '@iconify/react';
@@ -29,6 +31,7 @@ interface Props {
}
const PreSelectedMatchers: React.FC = ({labelNames}) => {
+ 'use no memo';
const [labelValuesMap, setLabelValuesMap] = useState>({});
const [isLoading, setIsLoading] = useState>({});
const metadata = useGrpcMetadata();
diff --git a/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx b/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx
index d020ace0ac7..03e9887d147 100644
--- a/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx
+++ b/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx
@@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+/* eslint-disable react-hooks/set-state-in-effect */
+
import {useEffect, useRef, useState} from 'react';
import {useURLState} from '@parca/components';
@@ -64,6 +66,7 @@ function calculateTruncatedText(
}
function TextWithEllipsis({text, x, y, width}: Props): JSX.Element {
+ 'use no memo';
const textRef = useRef(null);
const [displayText, setDisplayText] = useState(text);
const [alignFunctionName] = useURLState('align_function_name');
diff --git a/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx b/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx
index 9688054782e..66350e32690 100644
--- a/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx
+++ b/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx
@@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+/* eslint-disable react-hooks/refs */
+
import React, {createContext, useCallback, useContext, useMemo, useRef} from 'react';
import {Table} from '@uwdata/flechette';
@@ -68,6 +70,7 @@ export const TooltipProvider: React.FC = ({
onTooltipUpdate,
tooltipId = 'default',
}) => {
+ 'use no memo';
const tooltipStateRef = useRef({row: null, x: 0, y: 0});
const updateTooltip = useCallback(
diff --git a/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx b/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx
index 4e9fe332081..c21253d4063 100644
--- a/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx
+++ b/ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx
@@ -11,6 +11,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+/* eslint-disable react-hooks/refs */
+
import React from 'react';
import {Icon} from '@iconify/react';
@@ -33,6 +35,7 @@ export const ZoomControls = ({
resetZoom,
portalRef,
}: ZoomControlsProps): React.JSX.Element => {
+ 'use no memo';
const controls = (