我是React,Redux和normalizr的新手。我尝试使用 normalizr 规范化我提取的数据。
鉴于此JSON:
{'teams': [
{
"id": 1,
"nom": "Team1"
},
{
"id": 2,
"nom": "Team2"
},
{
"id": 3,
"nom": "Team3"
}]}
我想将以下规范化模式应用于normalizr:
import { normalize, schema } from 'normalizr';
const teamSchema = new schema.Entity('teams');
const preloadedStateSchema = { teams: [ teamSchema ] };
const normalizedData = normalize(preloadedState, preloadedStateSchema);
我的期望:
{
entities: {
teams: {
1: {
"id": 1,
"nom": "Team1"
},
2: {
"id": 2,
"nom": "Team2"
},
3: {
"id": 3,
"nom": "Team3"
}
},
result:{
teams: [1, 2, 3]
}
}
我得到了什么:
{
entities: {
teams: {
1: **<EMPTY SLOT>**
2: {
"id": 2,
"nom": "Team2"
},
3: {
"id": 3,
"nom": "Team3"
}
},
result:{
teams: [1, 2, 3]
}
}
这个&#34;空位&#34;来自?如何解决这个问题?