typeweave

Documentation is under development.

mergeProps

Description

Merges multiple props objects into a single object, handling edge cases for event handlers, classNames, and styles.

Syntax

mergeProps(...props: object[]): Record<string, unknown>

Parameters

props: A variable number of objects to be merged.

Return Value

A single object containing the merged props.

Details

example

import { mergeProps } from '@typeweave/react-utils/merge-props';

export default function App() {
  const props1 = {
    onClick: () => console.log('Hello'),
    className: 'foo',
  };

  const props2 = {
    onClick: () => console.log('World'),
    className: 'bar',
  };

  return <div {...mergeProps(props1, props2)}></div>;
}