I was trying to change a file's name before uploading in my react.js
application:
Here is the approach :
onInputChange = (e) =>{
let newFileName='dp';
if(e.target.files.length!==0){
this.state.file=e.target.files[0];
Object.defineProperty(this.state.file.name, 'name', {
writable: true,
value: newFileName
});
console.log(this.state.file);
}
};
But the problem is, whenever this function gets called, I get an error saying : Object.defineProperty called on non-object
How this can be solved ?