- Source:
Methods
-
assignIfChanged(target, newProps, compare)
-
Merges the properties of
newPropsintotarget, like Object.assign. However, each property is compared with the existing property on thetargetobject. If the properties are equal, the property on thetargetobject will not be overwritten._note: This logic is applied for each top-level property of
newProps, but not for deeply nested properties. _This util is useful when we want to cause as little mutations to the target object as possible. For example, in reducers mutations to objects will generally cause attached selectors and React components to update.
Parameters:
Name Type Description targetObject The object to update properties on
newPropsObject An object containing new properties
comparefunction The function that will be used to compare properties from newProps to existing properties on target. Defaults to the lodash isEqual util.
- Source:
Returns:
A new object with the changed properties from newProps. If no properties have changed, will return a reference to the original object.
- Type
- Object