使用normalizr
库后,我的应用程序的 Redux 状态中有以下标准化 JSON 对象结果:
{
sports: {
byId: {
1: {
id: 1,
name: 'Soccer',
slug: 'soccer'
},
2: {
id: 2,
name: 'Basketball',
slug: 'basketball'
},
3: {
id: 3,
name: 'American Football',
slug: 'american-football'
}
},
allIds: [
'1',
'2',
'3'
]
},
competitions: {
byId: {
'1': {
id: 1,
name: 'Competition 1',
short_name: 'Comp 1',
slug: 'comp-1',
sport: 1,
status: {
is_live: false
}
},
'2': {
id: 2,
name: 'Competition 2',
short_name: 'Comp 2',
slug: 'comp-2',
sport: 1,
status: {
is_live: true
}
},
'3': {
id: 3,
name: 'National Basketball League',
short_name: 'NBA',
slug: 'national-basketball-league',
sport_slug: 'basketball',
sport: 3,
status: {
is_live: true
}
}
},
allIds: [
'1',
'2',
'3'
]
}
我想要实现的目标:我想要一个按 .competitions
过滤/分类的列表sports
。
我怎样才能做到这一点?
我也希望能够competitions
按它的status.is_live
.
那么我怎样才能得到一个等于真和等于假的细分列表呢competitions
?sport
status.is_live
competitions
status.is_live
任何帮助表示赞赏!谢谢