Redux 使用ImmutableJS将可变数据深度转换为不可变数据
我总是为下面的问题而头痛。我从restapi加载了一些数据,然后我想将其转换为redux的不可变状态 我的数据如下所示:Redux 使用ImmutableJS将可变数据深度转换为不可变数据,redux,react-redux,immutable.js,Redux,React Redux,Immutable.js,我总是为下面的问题而头痛。我从restapi加载了一些数据,然后我想将其转换为redux的不可变状态 我的数据如下所示: { name: 'Some string', components: [ { type: 'SomeType', name: 'Another string, components: [ { // and so on... } ] } ] } 可以
{
name: 'Some string',
components: [
{
type: 'SomeType',
name: 'Another string,
components: [
{
// and so on...
}
]
}
]
}
可以看出,数据嵌套得非常深,不可变的Map和List方法只转换第一级
我想知道如何将每个对象和数组转换为不可变状态。好的,事实证明它是非常先进的 我只需要使用
Immutable.fromJS