How To Remove Duplicate Value from Array in Reactjs ?

React.js

Nicesnippets

41424

31-10-2020


Now let's see example of how to remove duplicate value from array in reactjs. We will talk about reactjs remove duplicate value from array. you can simply delete duplicate value from array in Reactjs.

In this example i have simple array with duplicate values array and i will perform to get only unique values from array It is possible by filter. Its help to remove duplicate values from array in reactjs.

Example


import React from 'react'

export default class Home extends React.Component{

render(){

const depArray = [100,80, 70, 80, 90,100, 71, 80];

var newArray = [];

var newArray = depArray.filter(function(elem, pos) {

return depArray.indexOf(elem) == pos;

});

return(

{newArray}

);

}

}

It will help you...