So i tried to create a new object as a solution for an issue that I had in my code. But when I tried to create a new object with the updated values it doesn't return the old values. just the updated value. what could be the issue? Had to create a new object instead of modifying the existing one because some values are read only.
Here is the function that check for duplicate files,
const beforeUpload = (event: any) => {
const file: any = event?.target?.files[0];
const duplicateFile= fileList.find((files)=>{
return files.name==file?.name;
})
if(duplicateFile){
console.log(duplicateFile);
const updatedFile={
...duplicateFile,
name:`${duplicateFile.name}(${duplicateCount})`
};
console.log(updatedFile);
setDuplicateCount(duplicateCount+1);
}
if (!file) {
return;
}
takes a file and checks whether the file name already exists or not. And add a number to the end of the file name. i want to create a new object with the update name. Thats where I get the issue.
Here is the console output, The object on the top is what function receiving and the bottom one is the output. TIA.

updatedFileare not enumerable. Check the duplicates on how to correctly clone a file obejct.