It is not a bad idea to return record instance since Immutable.js
will handle that for you. Your whole redux tree will be immutable therefore it will only be changed by its set of operations.
As mentioned here
Data encapsulated in an Immutable.JS object is never mutated. A new copy is always returned.
Workflow
Immutable.js
makes data Persistant, therefore previous copies of the data is available and shares data via hash maps tries and vector tries.
Therefore there is no requirement to involve a costly operation such as cloning the data.
Need to copy the data from the cache is minimized which results it in being way more faster that the clone operation. It avoids creating new objects if there is no change in value.
Another thing to note is both Object.assign
and spread operator
are shallow operations. Hence, you need to do more modifications for nested operations.
You can check the performance of both here