Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6208

Delete a key from a copy of Map object

$
0
0

I'm trying to delete a key of my react-native state Map object.

const [errors, setErrors] = useState<Map<string, string>>(null);
let copy: Map<string,string> = {...errors}
copy["a"] = "a";
setErrors(copy);
let copy2: Map<string,string> = {...errors};
copy2.delete("a"); //Got error here
setErrors(copy2);

But i've this error :

copy2.delete is not a function (In 'copy2.delete("a"),'copy2.delete' is undefined)

How to handle that ?


Viewing all articles
Browse latest Browse all 6208

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>