How does immutable.js #get work?

冷暖自知 提交于 2019-12-12 05:28:35

问题


I know how Map() can create an empty Map object, but how does the get here work?? Does it mean it will get get the value from the active key and if there isn't a key there, it will create an empty Map object? Where is the docs for this?

const activeSelector = createSelector(
  rootSelector,
  (root) => root.get('active', Map())
);

回答1:


Yes, that's how it works. In your example, if active is not a key, it will return a new Map. This is defined in the docs for get()

Returns the value associated with the provided key, or notSetValue if the Collection does not contain this key.



来源:https://stackoverflow.com/questions/44208070/how-does-immutable-js-get-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!