2
我需要規範化這些數據,以便我有一個列表數組和另一個待辦事項列表。normalizr模式中的嵌套數組
const data = [
{
_id: '1',
title: 'List1',
todos: [
{
_id: "11",
text: "Test1"
}
]
},
{
_id: '2',
title: 'List2',
todos: [
{
_id: "22",
text: "Test2"
}
]
}
];
這裏就是我的了:
const todo = new schema.Entity('todos',{},{ idAttribute: '_id'});
const list = new schema.Entity('lists',{todos:todo},{idAttribute: '_id'});
const normalizedData = normalize(data, list);
console.log(normalizedData);
我一直想自己的例子,但沒有人似乎爲這一數據的工作。
任何幫助,將不勝感激。
哪裏'redux'和'react'? – lux