在 Immutable 中扩展属性

Extending properties in Immutable

我正在将这段代码块转换为不可变的,但不知道如何在不可变对象上扩展我的 prop。有人可以告诉我怎么做吗?我正在扩展 prop,所以我的不可变对象从另一个模块获取返回结果。目前,populateKey 也是从外部设置的,我设法封装了它。帮助!! <3

你可以使用setIn方法

return state.setIn([populateKey, 'type'], result.type).setIn([...])

setIn(keyPath: Array, value: any): Map