🐛 fix(inputListComponent): set inputList state to value prop on value prop change to fix inputList not updating on prop change

🔒 chore(utils.ts): add random number to getRandomKeyByssmm function to reduce the chance of key collision
This commit is contained in:
Cristhian Zanforlin Lousa 2023-06-23 19:18:31 -03:00
commit 4e01de9e39
2 changed files with 6 additions and 1 deletions

View file

@ -19,6 +19,11 @@ export default function InputListComponent({
onChange([""]);
}
}, [disabled, onChange]);
useEffect(() => {
setInputList(value);
}, [value]);
return (
<div
className={

View file

@ -971,5 +971,5 @@ export function getRandomKeyByssmm(): string {
const now = new Date();
const seconds = String(now.getSeconds()).padStart(2, "0");
const milliseconds = String(now.getMilliseconds()).padStart(3, "0");
return seconds + milliseconds;
return seconds + milliseconds + Math.abs(Math.floor(Math.random() * 10001));
}