@metamask/design-system-react-native
Version:
32 lines • 1.06 kB
JavaScript
function $importDefault(module) {
if (module?.__esModule) {
return module.default;
}
return module;
}
import $React, { useEffect, useState } from "react";
const React = $importDefault($React);
import { View } from "react-native/index.js";
import { SvgXml } from "react-native-svg";
import { getMaskiconSVG } from "./Maskicon.utilities.mjs";
export const Maskicon = ({ address, size = 32, ...props }) => {
const [svgString, setSvgString] = useState('');
useEffect(() => {
let cancelled = false;
// eslint-disable-next-line no-void
void (async () => {
const newSvg = await getMaskiconSVG(address, size);
if (!cancelled) {
setSvgString(newSvg);
}
})();
return () => {
cancelled = true;
};
}, [address, size]);
if (!svgString) {
return <View style={{ width: size, height: size }}/>;
}
return <SvgXml xml={svgString} width={size} height={size} {...props}/>;
};
//# sourceMappingURL=Maskicon.mjs.map