问题
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