File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ export function useParallax<T extends HTMLElement>(props: ParallaxProps) {
24
24
} ;
25
25
newElement = controller ?. createElement ( options ) ;
26
26
setElement ( newElement ) ;
27
+ } else if ( ref . current === null ) {
28
+ // if the ref is null, do nothing
29
+ return ;
27
30
} else {
28
31
throw new Error (
29
32
'You must assign the ref returned by the useParallax() hook to an HTML Element.'
@@ -35,7 +38,7 @@ export function useParallax<T extends HTMLElement>(props: ParallaxProps) {
35
38
controller ?. removeElementById ( newElement . id ) ;
36
39
}
37
40
} ;
38
- } , [ ] ) ;
41
+ } , [ ref . current ] ) ;
39
42
40
43
// update element
41
44
useEffect ( ( ) => {
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import styles from './Image.module.scss';
5
5
export const Image = ( props ) => {
6
6
const parallaxController = useParallaxController ( ) ;
7
7
function handleLoad ( ) {
8
- parallaxController . update ( ) ;
8
+ parallaxController ? .update ( ) ;
9
9
}
10
10
return (
11
11
< div className = { styles . image } >
You can’t perform that action at this time.
0 commit comments