remove duplicate items from an array in react code example
Example: remove duplicate id in list react jsx
<div id="root">
</div>
<script type="text/es2015">
function MyFunction() {
var myArray = ['100', '120', '130', '140', '500', '100', '120', '140'];
var result = [];
result = myArray.filter(function(item, pos, self) {
return self.indexOf(item) == pos;
})
var items = result.map((item) =>
item+','
);
return (
<p>{items}</p>
);
}
ReactDOM.render(
<MyFunction />,
document.getElementById('root')
);
</script>