1.0.3 • Published 6 months ago
react-merge-props v1.0.3
react-merge-props
Deep props merging functionality for React.
Introduction
Merging react component props by the following rule:
- Normal props replace the former
className
are concatenatedstyle
are shallow merged- functions are run in sequence from left to right
When creating extensible react components, this is what we need.
Installation
Install this package with npm
.
npm i react-merge-props -s
Usage Pattern
This package is very useful when creating wrapping components. For example:
import React from 'react';
import mergeProps from 'react-merge-props';
const HeadingOne = (props) => (
<h1 {...mergeProps({ style: { 'color': 'red' }}, props)} />
);
export default HeadingOne;
License
MIT © Victor Teo