I am practicing with React and sorting lists. Now I have an array with object, a value of an object is' isDeleted 'by default it is 0, if the user deletes the item this is 1. All values are' mapped 'in a list, it is possible to change the objects with' isDeleted === 1 'from this list. currently this is my code for rendering the list:
{
this.state.questions.sort(function(a, b) { return a.isDeleted-b.isDeleted;}).map((question, i) => (
<li key={i}><span className="question-list">{question.vraag}</span> <span className="see-list-delete"><a onClick={() => this.deleteQuestion(question.key,i)}><i class="far fa-trash-alt"></i></a></span> <span className="see-list-edit"><a href="#"><i class="far fa-edit"></i></a></span></li>
))
}
An object in the array has the following structure:
{id: state.id, setname: state.setname, categoryName: state.categoryName, vraag: state.vraag, key: state.key, isDeleted: state.isDeleted}
So if isDeleted 1is it should not be visible in the map
array.filter()