Skip to content

Commit a0ab4ba

Browse files
committed
use generic for useParallax ref
1 parent c5eef8a commit a0ab4ba

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/components/Parallax/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ export function Parallax(props: PropsWithChildren<ParallaxProps>) {
1919
);
2020
}
2121

22+
export const Component = () => {
23+
const { ref } = useParallax<HTMLDivElement>({ translateY: [100, -100] });
24+
return (
25+
<div ref={ref}>
26+
<div />
27+
</div>
28+
);
29+
};
30+
2231
Parallax.defaultProps = {
2332
disabled: false,
2433
innerTag: 'div',

src/hooks/useParallax.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { ParallaxProps } from '../types';
55
import { removeUndefinedObjectKeys } from '../utils/removeUndefinedObjectKeys';
66
import { useController } from './useController';
77

8-
export function useParallax(props: ParallaxProps) {
8+
export function useParallax<T extends HTMLElement>(props: ParallaxProps) {
99
const controller = useController();
10-
const ref = useRef<HTMLElement>();
10+
const ref = useRef<T>(null);
1111

1212
useVerifyController(controller);
1313

0 commit comments

Comments
 (0)