fix: env ID generation and React state synchronization
This commit is contained in:
6
src/componets/env/Environment.tsx
vendored
6
src/componets/env/Environment.tsx
vendored
@@ -44,8 +44,12 @@ export function Environment(props: { envs: Env[], onChanged: (env: Env) => void,
|
||||
const name = prompt("Enter new environment name:");
|
||||
if (!name || name.trim() === "") return;
|
||||
|
||||
// Calculate next integer ID based on max existing ID
|
||||
const maxId = props.envs.reduce((max, e) => Math.max(max, e.id ?? 0), -1);
|
||||
const newId = maxId + 1;
|
||||
|
||||
const newEnv = new Env(
|
||||
Math.random() * 10000,
|
||||
newId,
|
||||
name.trim(),
|
||||
[...currEnv.params]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user