@evergis/react 3.1.129 → 3.1.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +12 -7
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +12 -7
- package/dist/react.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -11681,19 +11681,24 @@ const StyledSvg = styled(uilibGl.Flex) `
|
|
|
11681
11681
|
|
|
11682
11682
|
const SvgImage = React.memo(({ url, width, height, fontColor }) => {
|
|
11683
11683
|
const [svg, setSvg] = React.useState(null);
|
|
11684
|
-
const
|
|
11685
|
-
React.
|
|
11686
|
-
if (!url ||
|
|
11684
|
+
const loadingRef = React.useRef(false);
|
|
11685
|
+
const fetchSvg = React.useCallback(() => {
|
|
11686
|
+
if (!url || loadingRef.current)
|
|
11687
11687
|
return;
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
fetch(url
|
|
11688
|
+
loadingRef.current = true;
|
|
11689
|
+
const token = window.localStorage.getItem(api.STORAGE_TOKEN_KEY);
|
|
11690
|
+
fetch(url, {
|
|
11691
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {},
|
|
11692
|
+
})
|
|
11691
11693
|
.then(res => (res.ok ? res.text() : null))
|
|
11692
11694
|
.then(setSvg)
|
|
11693
11695
|
.finally(() => {
|
|
11694
|
-
|
|
11696
|
+
loadingRef.current = false;
|
|
11695
11697
|
});
|
|
11696
11698
|
}, [url]);
|
|
11699
|
+
React.useEffect(() => {
|
|
11700
|
+
fetchSvg();
|
|
11701
|
+
}, [fetchSvg]);
|
|
11697
11702
|
React.useEffect(() => () => {
|
|
11698
11703
|
setSvg(null);
|
|
11699
11704
|
}, []);
|