Skip to content

Commit 872b6f6

Browse files
committed
move random name generation to useState
1 parent 6585865 commit 872b6f6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/components/Dialogs/KubectlCommandInfo/KubectlCreateProjectDialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { KubectlBaseDialog, FormField, CustomCommand } from './KubectlBaseDialog';
22
import { useTranslation } from 'react-i18next';
3+
import { useState } from 'react';
34

45
interface KubectlCreateProjectDialogProps {
56
onClose: () => void;
@@ -8,7 +9,7 @@ interface KubectlCreateProjectDialogProps {
89

910
export const KubectlCreateProjectDialog = ({ onClose, isOpen }: KubectlCreateProjectDialogProps) => {
1011
const { t } = useTranslation();
11-
const randomProjectName = Math.random().toString(36).substring(2, 8);
12+
const [randomProjectName] = useState(() => Math.random().toString(36).substring(2, 8));
1213

1314
const formFields: FormField[] = [
1415
{

src/components/Dialogs/KubectlCommandInfo/KubectlCreateWorkspaceDialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { KubectlBaseDialog, FormField, CustomCommand } from './KubectlBaseDialog';
22
import { useTranslation } from 'react-i18next';
3+
import { useState } from 'react';
34

45
interface KubectlCreateWorkspaceDialogProps {
56
onClose: () => void;
@@ -9,7 +10,7 @@ interface KubectlCreateWorkspaceDialogProps {
910

1011
export const KubectlCreateWorkspaceDialog = ({ onClose, isOpen, project }: KubectlCreateWorkspaceDialogProps) => {
1112
const { t } = useTranslation();
12-
const randomWorkspaceName = Math.random().toString(36).substring(2, 8);
13+
const [randomWorkspaceName] = useState(() => Math.random().toString(36).substring(2, 8));
1314
const projectName = project || '<Project Namespace>';
1415
const projectNamespace = `project-${projectName}`;
1516

0 commit comments

Comments
 (0)