Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
79 views
in Technique[技术] by (71.8m points)

javascript - Filter multiple lists React

I have 6 lists, each list has an ID that link it to previous list, for example:

List 1: [
 {id:1, name: 'list1item1'}, 
 {id:2, name: 'list1item2'}, 
 {id:3, name: 'list1item3'}, 
 {id:4, name: 'list1item4'}, 
]

List 2: [
 {id:1, name: 'list2item1', list1id:3},
 {id:2, name: 'list2item2', list1id:3},  
 {id:3, name: 'list2item3', list1id:4}    
]

List 3: [
 {id:1, name: 'list3item1', list2id:1},
 {id:2, name: 'list3item2', list2id:2},  
 {id:3, name: 'list3item3', list2id:1}    
]

each object of each list is an checkbox, by clicking one of it I need to filter previous and next lists by the selected item. For example if I select items with name list2item1 and list2item3, the List1 must contain list1item3 and list1item4 and List3 must contain list3item1 and list3item3. I tried to do a recursive function, but maybe I wrote it incorrect, because it doesn't filter ok. What is the best method to do this?

Thank you in advance!

question from:https://stackoverflow.com/questions/65640999/filter-multiple-lists-react

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...