admin管理员组文章数量:1426023
I know it is probably a silly question but I can' find an answer by myself, so..
How can I get current index
with this construction .map(([key, value])
?
to access it inside the map function bellow
return (
<Fragment>
{Object.entries(props.values).map(([key, value]) => {
return (
<Button
key={key}
value={value}
/>
);
})}
</Fragment>
);
I know it is probably a silly question but I can' find an answer by myself, so..
How can I get current index
with this construction .map(([key, value])
?
to access it inside the map function bellow
return (
<Fragment>
{Object.entries(props.values).map(([key, value]) => {
return (
<Button
key={key}
value={value}
/>
);
})}
</Fragment>
);
Share
Improve this question
asked May 6, 2020 at 17:06
AndrewAndrew
7951 gold badge10 silver badges23 bronze badges
1 Answer
Reset to default 6You can obtain an index from callback in map
return (
<Fragment>
{Object.entries(props.values).map(([key, value], index) => {
return (
<Button
key={key}
value={value}
/>
);
})}
</Fragment>
);
Please check https://developer.mozilla/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
本文标签: javascriptGet current index of an item with Objectentries()mapStack Overflow
版权声明:本文标题:javascript - Get current index of an item with Object.entries().map - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745398824a2656942.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论