Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

default-props

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

default-props

Auto populate default props for react components

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Default Props

Dependabot badge Dependencies Build Status Coverage Status

Auto populate default props for react components

Usage

npm i default-props
import * as PropTypes from 'prop-types'
import { defaultProps } from 'default-props'

function Component(props) {
  return <abc {...props} />
}

Component.propTypes = {
  b: PropTypes.bool,
  n: PropTypes.number,
  f: PropTypes.func,
  s: PropTypes.string,
}

Component.defaultProps = defaultProps(Component)

You can also selectively combine props

Component.defaultProps = {
  ...defaultProps({ ...Component, keys: ['n', 's'] })
  ...defaultProps({ ...Component, defaults: false, keys: ['b'] })
  ...defaultProps({ ...Component, defaults: () => {}, keys: ['f'] })
}

Keywords

FAQs

Package last updated on 03 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc