Skip to content

Commit

Permalink
fix: remove ref from HintProps and set default to any
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Webb authored and Brandon Webb committed Sep 20, 2021
1 parent 63bb543 commit b8ce205
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/ReactImageMagnify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,13 @@ export const ReactImageMagnify = (props: ReactImageMagnifyProps): JSX.Element =>
activationInteractionHint === INTERACTIONS.click
|| activationInteractionHint === INTERACTIONS.hover
) ? (
// @ts-expect-error
<HintComponent
{...hintProps}
hintTextMouse={hintProps?.hintTextMouse || `${capitalize(activationInteractionHint)} to Zoom`}
hintTextTouch={hintProps?.hintTextTouch || 'Long-Touch to Zoom'}
isMouseDetected={isMouseDetected}
isTouchDetected={isTouchDetected}
style={generateHintStyle(hintProps?.style)}
{...hintProps}
onClick={lockedByHintInteraction ? handleHintClick : undefined}
onTouchEnd={lockedByHintInteraction ? handleHintTouchEnd : undefined}
/>
Expand Down
8 changes: 3 additions & 5 deletions src/hint/DefaultHint.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable react/prop-types */
import { forwardRef, memo, MutableRefObject } from 'react';
import { memo } from 'react';
import type { HintProps } from 'src/types';

export const DefaultHint = memo(forwardRef<HTMLElement, HintProps<HTMLElement>>((props, ref): JSX.Element => {
export const DefaultHint = memo((props: HintProps<HTMLDivElement>): JSX.Element => {
const {
isMouseDetected,
isTouchDetected,
Expand All @@ -24,7 +23,6 @@ export const DefaultHint = memo(forwardRef<HTMLElement, HintProps<HTMLElement>>(
...style,
}}
{...rest}
ref={ref as MutableRefObject<HTMLDivElement>}
>
<div
style={{
Expand Down Expand Up @@ -56,4 +54,4 @@ export const DefaultHint = memo(forwardRef<HTMLElement, HintProps<HTMLElement>>(
</div>
</div>
);
}));
});
8 changes: 2 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type {
ForwardRefExoticComponent,
HTMLProps,
ImgHTMLAttributes,
MemoExoticComponent,
TouchEvent as ReactTouchEvent,
} from 'react';
import type {
Expand Down Expand Up @@ -84,7 +83,7 @@ export interface LensProps extends HTMLProps<HTMLDivElement> {
position: Point;
}

export interface HintProps<T extends HTMLElement = HTMLElement> extends HTMLProps<T> {
export interface HintProps<T extends HTMLElement = any> extends Omit<HTMLProps<T>, 'ref'> {
isMouseDetected?: boolean;
isTouchDetected?: boolean;
hintTextMouse: string;
Expand Down Expand Up @@ -136,10 +135,7 @@ CursorPositionProps,
activationInteractionMouse?: Interactions['click'] | Interactions['hover'];
activationInteractionTouch?: Interactions['press'] | Interactions['tap'] | Interactions['touch'];
fadeDurationInMs?: number;
hintComponent?: ComponentType<HintProps>
| ForwardRefExoticComponent<HintProps>
| MemoExoticComponent<ComponentType<HintProps>
| ForwardRefExoticComponent<HintProps>>;
hintComponent?: ComponentType<HintProps>;
hintProps?: HintProps;
hoverDelayInMs?: number;
hoverOffDelayInMs?: number;
Expand Down

0 comments on commit b8ce205

Please sign in to comment.