Im trying to save some data into a state using object keys in react,
Ex : setText(data[listname][0].feature-type;
But after saving the file it automatically adding a space between featute and type
Ex: setText(data[listname][0].feature - type:
As it is this will resulted as reference error.How to avoid this
setText(data[listname][0]['feature-type']. Because there are some limitations to which names can be accessed with a dot (.). And since the property name contains hífen (-), it needs to be accessed as a dictionary. VSCode is formatting different then what you expect because you are giving it invalid syntax.