JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4190
  • Score
    100M100P100Q112300F
  • License MIT

Generate default props based on your React component's PropTypes

Package Exports

  • react-generate-props

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-generate-props) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-generate-props

Generate default props based on your React component's PropTypes

Coverage Status CircleCI

Installation

$ npm install --save-dev react-generate-props

Usage

// react-component.jsx

class Component extends React.Component {
  static propTypes = {
    title: React.PropTypes.string.isRequired,
    count: React.PropTypes.number.isRequired
  }

  render() {
    <div>
      <h1>{this.props.title}</h1>
      <small>{this.props.count}</small>
    </div>
  }
}

export default Component
// component-test.js

import generateProps from 'react-generate-props'
import Component from './react-component'

const props = generateProps(Component)
assertEqual(props, { title: 'A String', count: 1 })

render(<Component {...props}/>)

/***
Result:

<div>
  <h1>A String</h1>
  <small>1</small>
</div>

***/