withProps()function
withProps(input: T, props: Partial<T>): T
withProps(input: T, props: T | Partial<T> | Iterable<Prop<T>>): T
| Param | Type | |
|---|---|---|
input | T | The object to set the props on. required |
props | Partial<T> | The props to set, as an object or iterable set of key/value entry tuples. required |
input | T | required |
props | TPartial<T>Iterable<Prop<T>> | required |
| Return | |
|---|---|
T | A new object including the set props, or the original object if all values were unchanged. |
T |
Set several props on an object (immutably) and return a new object including those props.
- If all values are unchanged the original object is returned unchanged.
Examples
withProps({ a: 1 }, { b: 2, c: 3 }); // { a: 1, b: 2, c: 3 }