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) {
2424 } ;
2525 newElement = controller ?. createElement ( options ) ;
2626 setElement ( newElement ) ;
27+ } else if ( ref . current === null ) {
28+ // if the ref is null, do nothing
29+ return ;
2730 } else {
2831 throw new Error (
2932 '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) {
3538 controller ?. removeElementById ( newElement . id ) ;
3639 }
3740 } ;
38- } , [ ] ) ;
41+ } , [ ref . current ] ) ;
3942
4043 // update element
4144 useEffect ( ( ) => {
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import styles from './Image.module.scss';
55export const Image = ( props ) => {
66 const parallaxController = useParallaxController ( ) ;
77 function handleLoad ( ) {
8- parallaxController . update ( ) ;
8+ parallaxController ? .update ( ) ;
99 }
1010 return (
1111 < div className = { styles . image } >
You can’t perform that action at this time.
0 commit comments