[英]how can I put a logic in map array method. I have sent title as props and except props title I want to render other title
You are returning the option directly from your map function, if you want to add logic inside just add {}
and a return
statement inside您直接从 map function 返回选项,如果您想在里面添加逻辑,只需添加
{}
和里面的return
语句
{coins.map((item) => {
// you can put your logic here
// for example just first 2 letters
const customTitle = item.title.slice(0, 2)
return (
<option>{customTitle}</option>
)
})}
You can read more about arrow functions
here您可以在此处阅读有关
arrow functions
的更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.