npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cozka/react-merge

v0.1.4

Published

`@cozka/react-merge` is a utility package that provides simple functions for merging React component props. It’s especially useful when you want to combine multiple `ref`s, `className`s, `style`s, or event handlers cleanly.

Downloads

9

Readme

@cozka/react-merge

@cozka/react-merge is a utility package that provides simple functions for merging React component props. It’s especially useful when you want to combine multiple refs, classNames, styles, or event handlers cleanly.

日本語のREADMEはこちら


Installation

npm install @cozka/react-merge

Usage

import mergeProps from '@cozka/react-merge/mergeProps';
import { forwardRef, useRef } from 'react';

const App = forwardRef((props, ref) => {
  const myRef = useRef();

  const newProps = mergeProps(
    {
      ref: [ref, myRef],
      className: 'app',
      style: { backgroundColor: 'red' },
      onChange: (event) => console.log(event),
    },
    props,
  );

  return <div {...newProps}>App</div>;
});

With mergeProps, you can easily combine multiple sets of props into a single, clean object.


API

mergeRef(...refList)

Combines multiple refs into a single function ref.

Parameters

| Name | Type | Description | | --------- | --------------------------------------- | ------------------------------------------------------------------- | | refList | (Ref \| false \| null \| undefined)[] | An array of refs. false, null, and undefined will be ignored. |

Returns

A function that assigns the value to all provided refs.


mergeClassName(...classNameList)

Concatenates multiple className strings with spaces.

Parameters

| Name | Type | Description | | --------------- | ------------------------------------------ | -------------------------------------------------------------------------- | | classNameList | (string \| false \| null \| undefined)[] | An array of class names. false, null, and undefined will be ignored. |

Returns

A single string combining all valid class names with spaces.


mergeStyle(...styleList)

Merges multiple style objects into one.

Parameters

| Name | Type | Description | | ----------- | ------------------------------------------------- | ------------------------------------------------------------------------ | | styleList | (CSSProperties \| false \| null \| undefined)[] | An array of style objects. false, null, and undefined are ignored. |

Returns

A single style object. Later styles override earlier ones in case of overlap.


mergeHandler(...handlerList)

Creates a single function that calls multiple event handlers in sequence.

Parameters

| Name | Type | Description | | ------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------------- | | handlerList | (((...args: any[]) => void) \| false \| null \| undefined)[] | An array of event handlers. false, null, and undefined will be ignored. |

Returns

A function that calls all valid handlers in order.


mergeProps(...propsList)

Combines multiple props objects into a single one that can be passed to a React element.

Parameters

| Name | Type | Description | | ----------- | ------------------------------------------------------------------------------------------------------------------------- | ---------------------- | | propsList | { ref: Ref \| Ref[]; className: string \| string[]; style: CSSProperties \| CSSProperties[]; [key: string]: unknown }[] | Array of props objects |

Returns

A single merged props object based on the following rules:


License

MIT