Handle refs properly for token and map images
This commit is contained in:
parent
d55514ef7c
commit
cd498167aa
@ -4,7 +4,7 @@ import { Image } from "theme-ui";
|
|||||||
import { useDataURL } from "../../contexts/AssetsContext";
|
import { useDataURL } from "../../contexts/AssetsContext";
|
||||||
import { mapSources as defaultMapSources } from "../../maps";
|
import { mapSources as defaultMapSources } from "../../maps";
|
||||||
|
|
||||||
const MapTileImage = React.forwardRef(({ map, ...props }) => {
|
const MapTileImage = React.forwardRef(({ map, ...props }, ref) => {
|
||||||
const mapURL = useDataURL(
|
const mapURL = useDataURL(
|
||||||
map,
|
map,
|
||||||
defaultMapSources,
|
defaultMapSources,
|
||||||
@ -12,7 +12,7 @@ const MapTileImage = React.forwardRef(({ map, ...props }) => {
|
|||||||
map.type === "file"
|
map.type === "file"
|
||||||
);
|
);
|
||||||
|
|
||||||
return <Image src={mapURL} {...props} />;
|
return <Image src={mapURL} ref={ref} {...props} />;
|
||||||
});
|
});
|
||||||
|
|
||||||
export default MapTileImage;
|
export default MapTileImage;
|
||||||
|
@ -5,7 +5,7 @@ import { useDataURL } from "../../contexts/AssetsContext";
|
|||||||
|
|
||||||
import { tokenSources as defaultTokenSources } from "../../tokens";
|
import { tokenSources as defaultTokenSources } from "../../tokens";
|
||||||
|
|
||||||
const TokenImage = React.forwardRef(({ token, ...props }) => {
|
const TokenImage = React.forwardRef(({ token, ...props }, ref) => {
|
||||||
const tokenURL = useDataURL(
|
const tokenURL = useDataURL(
|
||||||
token,
|
token,
|
||||||
defaultTokenSources,
|
defaultTokenSources,
|
||||||
@ -13,7 +13,7 @@ const TokenImage = React.forwardRef(({ token, ...props }) => {
|
|||||||
token.type === "file"
|
token.type === "file"
|
||||||
);
|
);
|
||||||
|
|
||||||
return <Image src={tokenURL} {...props} />;
|
return <Image src={tokenURL} ref={ref} {...props} />;
|
||||||
});
|
});
|
||||||
|
|
||||||
export default TokenImage;
|
export default TokenImage;
|
||||||
|
Loading…
Reference in New Issue
Block a user