@snack-uikit/icons 0.22.0 → 0.22.1-preview-94780dcd.0

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/Sprite.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare function SpriteInner({ content }: {
3
2
  content: string;
4
3
  }): null;
package/dist/Sprite.js CHANGED
@@ -1,16 +1,24 @@
1
- import { useLayoutEffect, useState, memo } from 'react';
1
+ import { memo, useState } from 'react';
2
+ import { useLayoutEffect } from '@snack-uikit/utils';
2
3
  function SpriteInner({ content }) {
3
- const [div] = useState(() => document.createElement('div'));
4
+ const [div, setDiv] = useState();
4
5
  useLayoutEffect(() => {
5
- div.style.display = 'none';
6
- document.body.prepend(div);
7
- return () => {
8
- document.body.removeChild(div);
9
- };
6
+ setDiv(document.createElement('div'));
10
7
  }, []);
11
8
  useLayoutEffect(() => {
12
- div.innerHTML = content;
13
- }, [content]);
9
+ if (div) {
10
+ div.style.display = 'none';
11
+ document.body.prepend(div);
12
+ return () => {
13
+ document.body.removeChild(div);
14
+ };
15
+ }
16
+ }, [div]);
17
+ useLayoutEffect(() => {
18
+ if (div) {
19
+ div.innerHTML = content;
20
+ }
21
+ }, [content, div]);
14
22
  return null;
15
23
  }
16
24
  export const Sprite = memo(SpriteInner);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Icons",
7
- "version": "0.22.0",
7
+ "version": "0.22.1-preview-94780dcd.0",
8
8
  "sideEffects": [
9
9
  "*.svg",
10
10
  "*.css",
@@ -40,6 +40,9 @@
40
40
  "build:interface-icons": "npm run fix:icons --directory=interface-icons && npm run build:icons --directory=interface-icons",
41
41
  "compile": "npm run validate:icons && npm run build:interface-icons && npm run create-export-index-file && npm run create-sprite"
42
42
  },
43
+ "dependencies": {
44
+ "@snack-uikit/utils": "3.3.1-preview-94780dcd.0"
45
+ },
43
46
  "devDependencies": {
44
47
  "@svgr/cli": "8.1.0",
45
48
  "@svgr/plugin-jsx": "8.1.0",
@@ -49,5 +52,5 @@
49
52
  "svg-sprite": "2.0.2",
50
53
  "svgo": "3.1.0"
51
54
  },
52
- "gitHead": "4c153b54a2902cf20883d85b4dc753344313c6cb"
55
+ "gitHead": "0b67805c876ec8ccc1567d110a3b37b04d2f0fb6"
53
56
  }
package/src/Sprite.tsx CHANGED
@@ -1,20 +1,30 @@
1
- import { useLayoutEffect, useState, memo } from 'react';
1
+ import { memo, useState } from 'react';
2
+
3
+ import { useLayoutEffect } from '@snack-uikit/utils';
2
4
 
3
5
  function SpriteInner({ content }: { content: string }) {
4
- const [div] = useState(() => document.createElement('div'));
6
+ const [div, setDiv] = useState<HTMLDivElement>();
5
7
 
6
8
  useLayoutEffect(() => {
7
- div.style.display = 'none';
8
- document.body.prepend(div);
9
-
10
- return () => {
11
- document.body.removeChild(div);
12
- };
9
+ setDiv(document.createElement('div'));
13
10
  }, []);
14
11
 
15
12
  useLayoutEffect(() => {
16
- div.innerHTML = content;
17
- }, [content]);
13
+ if (div) {
14
+ div.style.display = 'none';
15
+ document.body.prepend(div);
16
+
17
+ return () => {
18
+ document.body.removeChild(div);
19
+ };
20
+ }
21
+ }, [div]);
22
+
23
+ useLayoutEffect(() => {
24
+ if (div) {
25
+ div.innerHTML = content;
26
+ }
27
+ }, [content, div]);
18
28
 
19
29
  return null;
20
30
  }