是否可以被嵌套結構如下減速器結合:嵌套終極版減速器
import 'user' from ...
import 'organisation' from ...
import 'auth' from ...
// ...
export default combineReducers({
auth: {
combineReducers({
user,
organisation,
}),
auth,
},
posts,
pages,
widgets,
// .. more state here
});
凡國家有結構:
{
auth: {
user: {
firstName: 'Foo',
lastName: 'bar',
}
organisation: {
name: 'Foo Bar Co.'
phone: '1800-123-123',
},
token: 123123123,
cypher: '256',
someKey: 123,
}
}
凡auth
減速機具有結構:
{
token: 123123123,
cypher: '256',
someKey: 123,
}
所以也許擴散算子是方便的? ...auth
不知道:-(
whoa ..好吧,這很好。雖然這是否意味着我的狀態樹中有'organisation'和'user'的多個副本? – AndrewMcLagan
是的,你絕對應該這個項目:https://github.com/mweststrate/redux-todomvc。這是使用這些技巧的todomvc的優化版本。 – Florent
我喜歡這個想法,儘管它似乎使應該很簡單的事情變得複雜。 :-( – AndrewMcLagan