Skip to content

Commit

Permalink
Forward refs
Browse files Browse the repository at this point in the history
  • Loading branch information
datobs committed Mar 11, 2022
1 parent 0d85a80 commit d4b6c65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/GlassMagnifier.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { forwardRef } from "react";
import PropTypes from "prop-types";
import utils from "./utils";
import ReactInputPosition, {
Expand All @@ -7,7 +7,7 @@ import ReactInputPosition, {
} from "react-input-position";
import GlassRenderer from "./GlassRenderer";

const GlassMagnifier = props => {
const GlassMagnifier = forwardRef((props, ref) => {
const {
imageSrc,
largeImageSrc,
Expand Down Expand Up @@ -63,10 +63,11 @@ const GlassMagnifier = props => {
onImageLoad={onImageLoad}
onLargeImageLoad={onLargeImageLoad}
portalTarget={portalTarget}
ref={ref}
/>
</ReactInputPosition>
);
};
});

GlassMagnifier.propTypes = {
imageSrc: PropTypes.oneOfType([
Expand Down
7 changes: 4 additions & 3 deletions src/GlassRenderer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import React, { forwardRef } from "react";
import { createPortal } from "react-dom";
import utils from "./utils";
import Image from "./Image";
import styles from "./styles";

const GlassRenderer = props => {
const GlassRenderer = forwardRef((props, ref) => {
const {
itemRef,
itemPosition,
Expand Down Expand Up @@ -101,11 +101,12 @@ const GlassRenderer = props => {
alt={imageAlt}
onImageLoad={onImageLoad}
onLoadRefresh={onLoadRefresh}
ref={ref}
/>
{glassNode}
{renderOverlay ? renderOverlay(active) : null}
</React.Fragment>
);
};
});

export default GlassRenderer;

0 comments on commit d4b6c65

Please sign in to comment.