react-default-props

A helper function to return a new react component with default props

Usage no npm install needed!

<script type="module">
  import reactDefaultProps from 'https://cdn.skypack.dev/react-default-props';
</script>

README

react-default-props

Build Status npm version

A helper function to return a new react component from an existing react component with a new set of default props

Install

npm install --save react-default-props

Signature

This function has two parameters

component

The React Component for which the default props should be modified.

defaultProps

The defaults that should be overridden as an object

Example Usage

var rdp = require('react-default-props');
var ReactDOM = require('react-dom');
var myComp = require('./MyComponent');
var myCompWithNewDefaults = rdp(myComp, {
    someDefaultProp: 'red',
    children: [ React.DOM.span({}, 'test') ]
});