@@ -18,7 +18,6 @@ const RESPONSIVE_OVERRIDE_WARNING = [
1818class Image extends CloudinaryComponent {
1919 constructor ( props , context ) {
2020 super ( props , context ) ;
21- this . imgElement = createRef ( ) ;
2221 this . placeholderElement = createRef ( ) ;
2322 this . state = { isLoaded : false }
2423 this . listenerRemovers = [ ] ;
@@ -33,7 +32,7 @@ class Image extends CloudinaryComponent {
3332 console . warn ( RESPONSIVE_OVERRIDE_WARNING ) ;
3433 }
3534
36- return responsive && this . imgElement && this . imgElement . current ;
35+ return responsive && this . element && this . element . current ;
3736 }
3837
3938 /**
@@ -95,7 +94,7 @@ class Image extends CloudinaryComponent {
9594 // Handle lazy loading
9695 if ( this . shouldLazyLoad ( ) ) {
9796 // Will set this.state.isInView = true when in view
98- Util . detectIntersection ( this . imgElement . current , this . onIntersect ) ;
97+ Util . detectIntersection ( this . element . current , this . onIntersect ) ;
9998 } else {
10099 // Handle responsive only if lazy loading wasn't requested or already handled
101100 if ( this . isResponsive ( ) ) {
@@ -109,29 +108,12 @@ class Image extends CloudinaryComponent {
109108 }
110109
111110 // Make original image responsive
112- const removeImgListener = makeElementResponsive ( this . imgElement . current , options ) ;
111+ const removeImgListener = makeElementResponsive ( this . element . current , options ) ;
113112 this . listenerRemovers . push ( removeImgListener ) ;
114113 }
115114 }
116115 }
117116
118- /**
119- * Attach both this.imgElement and props.innerRef as ref to the given element
120- * @param imgElement - the element to attach a ref to
121- */
122- attachRef = ( imgElement ) => {
123- const { innerRef} = this . props ;
124- this . imgElement . current = imgElement ;
125-
126- if ( innerRef ) {
127- if ( innerRef instanceof Function ) {
128- innerRef ( imgElement ) ;
129- } else {
130- innerRef . current = imgElement ;
131- }
132- }
133- } ;
134-
135117 shouldLazyLoad = ( ) => {
136118 const { loading} = this . getExtendedProps ( ) ;
137119 const { isInView} = this . state ;
0 commit comments