Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use arrow function instead of function expression - tslint error

Having tslint warnings (ES6) and still having some difficulty with its syntax.I am not sure how to convert to arrow functions.

[Image show the occurred warning][1]: https://i.sstatic.net/QCY69.png

var options = this.state.ProjectsArray.map(function (item, i) {
  var Trmp = item["ID"] + ";#" + item["Title"];
  return <option value={Trmp} key={item["ID"]}>{item["Title"]}</option> ;
});
like image 828
Mohamed Musthaque Avatar asked Apr 07 '26 01:04

Mohamed Musthaque


1 Answers

Like this

var options = this.state.ProjectsArray.map((item, i) => {
  var Trmp = item["ID"] + ";#" + item["Title"];
  return <option value={Trmp} key={item["ID"]}>{item["Title"]}</option> ;
});

Remove function word and put => after the parameters

like image 128
Suren Srapyan Avatar answered Apr 10 '26 02:04

Suren Srapyan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!