Handle refs properly for token and map images

This commit is contained in:
Mitchell McCaffrey 2021-05-25 18:06:26 +10:00
parent d55514ef7c
commit cd498167aa
2 changed files with 4 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import { Image } from "theme-ui";
import { useDataURL } from "../../contexts/AssetsContext";
import { mapSources as defaultMapSources } from "../../maps";
const MapTileImage = React.forwardRef(({ map, ...props }) => {
const MapTileImage = React.forwardRef(({ map, ...props }, ref) => {
const mapURL = useDataURL(
map,
defaultMapSources,
@ -12,7 +12,7 @@ const MapTileImage = React.forwardRef(({ map, ...props }) => {
map.type === "file"
);
return <Image src={mapURL} {...props} />;
return <Image src={mapURL} ref={ref} {...props} />;
});
export default MapTileImage;

View File

@ -5,7 +5,7 @@ import { useDataURL } from "../../contexts/AssetsContext";
import { tokenSources as defaultTokenSources } from "../../tokens";
const TokenImage = React.forwardRef(({ token, ...props }) => {
const TokenImage = React.forwardRef(({ token, ...props }, ref) => {
const tokenURL = useDataURL(
token,
defaultTokenSources,
@ -13,7 +13,7 @@ const TokenImage = React.forwardRef(({ token, ...props }) => {
token.type === "file"
);
return <Image src={tokenURL} {...props} />;
return <Image src={tokenURL} ref={ref} {...props} />;
});
export default TokenImage;