Skip to content

Commit df82d3f

Browse files
refactor: Move generateUniqueId function to utils
1 parent eb9b05d commit df82d3f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/components/sirenProvider.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type {
1111
} from '@sirenapp/js-sdk/dist/esm/types';
1212

1313
import type { SirenProviderConfigProps } from '../types';
14-
import { isNonEmptyArray, logger } from '../utils/commonUtils';
14+
import { generateUniqueId, isNonEmptyArray, logger } from '../utils/commonUtils';
1515
import {
1616
events,
1717
eventTypes,
@@ -76,10 +76,6 @@ export const useSirenContext = (): SirenContextProp => useContext(SirenContext);
7676
const SirenProvider: React.FC<SirenProvider> = ({ config, children }) => {
7777
let retryCount = 0;
7878

79-
const generateUniqueId = (): string => {
80-
return Math.random().toString(36).substring(2, 15);
81-
};
82-
8379
const { markAllAsViewed } = useSiren();
8480

8581
const [id] = useState(generateUniqueId());

src/utils/commonUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import { DefaultTheme } from './index';
88
export const isNonEmptyArray = (arr?: unknown[] | null) =>
99
Boolean(arr && typeof arr === 'object' && arr instanceof Array && arr.length > 0);
1010

11+
export const generateUniqueId = (): string => {
12+
return Math.random().toString(36).substring(2, 15);
13+
};
14+
1115
export const updateNotifications = (
1216
eventData: {
1317
id?: string;

0 commit comments

Comments
 (0)