withProps()function

withProps(input: T, props: Partial<T>): T
withProps(input: T, props: T | Partial<T> | Iterable<Prop<T>>): T
ParamType
inputT
The object to set the props on. required
propsPartial<T>
The props to set, as an object or iterable set of key/value entry tuples. required
inputT
required
propsT
Partial<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 }