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' } }

基于 MIT 许可证发布。