@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/react.esm.js CHANGED
@@ -11679,19 +11679,24 @@ const StyledSvg = styled(Flex) `
11679
11679
 
11680
11680
  const SvgImage = memo(({ url, width, height, fontColor }) => {
11681
11681
  const [svg, setSvg] = useState(null);
11682
- const [loading, setLoading] = useState(false);
11683
- useEffect(() => {
11684
- if (!url || loading) {
11682
+ const loadingRef = useRef(false);
11683
+ const fetchSvg = useCallback(() => {
11684
+ if (!url || loadingRef.current)
11685
11685
  return;
11686
- }
11687
- setLoading(true);
11688
- fetch(url)
11686
+ loadingRef.current = true;
11687
+ const token = window.localStorage.getItem(STORAGE_TOKEN_KEY);
11688
+ fetch(url, {
11689
+ headers: token ? { Authorization: `Bearer ${token}` } : {},
11690
+ })
11689
11691
  .then(res => (res.ok ? res.text() : null))
11690
11692
  .then(setSvg)
11691
11693
  .finally(() => {
11692
- setLoading(false);
11694
+ loadingRef.current = false;
11693
11695
  });
11694
11696
  }, [url]);
11697
+ useEffect(() => {
11698
+ fetchSvg();
11699
+ }, [fetchSvg]);
11695
11700
  useEffect(() => () => {
11696
11701
  setSvg(null);
11697
11702
  }, []);