Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {type ElementRef, useState, useCallback, useRef} from 'react';
import {type ElementRef, useState, useCallback, useRef, useEffect} from 'react';
import type {LayoutChangeEvent, LayoutRectangle, View as RNView} from 'react-native';
import _ from 'lodash';
import {HintProps} from '../types';
Expand All @@ -11,6 +11,14 @@ export default function useHintLayout({onBackgroundPress, targetFrame}: UseHintL
const [hintMessageWidth, setHintMessageWidth] = useState<number | undefined>();
const targetRef = useRef<ElementRef<typeof RNView> | null>(null);

useEffect(() => {
if (targetFrame && !_.isEqual(targetFrame, targetLayoutState)) {
setTargetLayout(targetFrame);
setTargetLayoutInWindow(targetFrame);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure regarding this line, cursor was insisting it's necessary due to lint issues that may come up without it but I didn't see an issue when removing this line, so leaving it up to your opinion..

}, [targetFrame]);

const onTargetLayout = useCallback(({nativeEvent: {layout}}: LayoutChangeEvent) => {
if (!_.isEqual(targetLayoutState, layout)) {
setTargetLayout(layout);
Expand Down