@cantoo/rn-svg
Version:
SVG library for react-native
24 lines • 680 B
JavaScript
import React, { useEffect, useState } from 'react';
import SvgXml from './SvgXml.web';
async function fetchText(uri) {
const response = await fetch(uri);
return await response.text();
}
const err = console.error.bind(console);
const SvgUri = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
const {
onError = err,
uri
} = props;
const [xml, setXml] = useState(null);
useEffect(() => {
uri ? fetchText(uri).then(setXml).catch(onError) : setXml(null);
}, [onError, uri]);
return /*#__PURE__*/React.createElement(SvgXml, {
ref: forwardRef,
xml: xml,
override: props
});
});
export default SvgUri;
//# sourceMappingURL=SvgUri.web.js.map