Skip to content

mergeProps

mergeProps is a utility function that merges multiple props objects into a single object. It handles merging of className, style, and function properties.

Interface

ts
function mergeProps<PropsList>(
  props: PropsList
): TupleToIntersection<PropsList>;

Parameters

  • propsrequired · PropsList

    The props objects to merge.

Return Value

  • TupleToIntersection<PropsList>

    merged props object.

Example

tsx
const mergedProps = mergeProps(
  { className: 'foo', style: { color: 'red' } },
  { className: 'bar', style: { backgroundColor: 'blue' } }
);
console.log(mergedProps); // { className: 'foo bar', style: { color: 'red', backgroundColor: 'blue' } }

Released under the MIT License.