Skip to content

Commit 2c8e9f2

Browse files
committed
chore: Bump package version to 1.1.4 and update build-icons script for output directory
1 parent 9722887 commit 2c8e9f2

File tree

3 files changed

+1343
-14
lines changed

3 files changed

+1343
-14
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@programmer_network/yail",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "Programmer Network's official UI library for React",
55
"author": "Aleksandar Grbic - (https://programmer.network)",
66
"publishConfig": {
@@ -33,7 +33,7 @@
3333
"dev": "vite",
3434
"build": "tsc && vite build",
3535
"build:watch": "VITE_WATCH=true vite build --watch",
36-
"build-icons": "npx @svgr/cli --typescript --jsx-runtime=automatic --prettier-config=./.prettierrc -d src/Components/Icons assets/icons",
36+
"build-icons": "npx @svgr/cli --typescript --jsx-runtime=automatic --prettier-config=./.prettierrc --out-dir src/Components/Icons assets/icons",
3737
"prepare": "husky",
3838
"storybook": "storybook dev --ci -p 6006",
3939
"format": "prettier --write .",

src/Components/Icon/index.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
ComponentType,
33
FC,
4-
LazyExoticComponent,
54
SVGProps,
65
Suspense,
76
lazy,
@@ -13,28 +12,24 @@ import { IIconProps } from "./types";
1312

1413
const iconCache: Record<
1514
string,
16-
LazyExoticComponent<ComponentType<SVGProps<SVGElement>>>
15+
React.LazyExoticComponent<ComponentType<SVGProps<SVGElement>>>
1716
> = {};
1817

1918
const Icon: FC<IIconProps> = props => {
2019
const { iconName, className, onClick, dataTestId, ...rest } = props;
21-
22-
const [error, setError] = useState<boolean>(false);
20+
const [error, setError] = useState(false);
2321

2422
const IconComponent = useMemo(() => {
2523
if (iconCache[iconName]) {
2624
return iconCache[iconName];
2725
}
2826

29-
const Component = lazy(async () => {
30-
try {
31-
const module = await import(`../Icons/${String(iconName)}.tsx`);
32-
return module;
33-
} catch {
27+
const Component = lazy(() =>
28+
import(`../Icons/${iconName}.tsx`).catch(() => {
3429
setError(true);
3530
return { default: () => null };
36-
}
37-
});
31+
})
32+
);
3833

3934
iconCache[iconName] = Component;
4035
return Component;
@@ -45,7 +40,7 @@ const Icon: FC<IIconProps> = props => {
4540
}
4641

4742
return (
48-
<Suspense>
43+
<Suspense fallback={null}>
4944
<IconComponent
5045
{...rest}
5146
className={className}

0 commit comments

Comments
 (0)