@traveloka/prop-types

0.1.4 • Public • Published

prop-types

CircleCI codecov

Custom prop-types used in Traveloka project for react prop validation that can't be covered using compile-time typecheck (such as Flow/Typescript)

API

ElementWithProps

Used to validate certain prop to equal react element with predefined props

Example:

import { ElementWithProps } from '@traveloka/prop-types';

const B = () => null;
const A = () => null;

A.propTypes = {
  b: ElementWithProps(B, { x: 'y', other: PropTypes.string })
}

// fail
<A b={<B />} />
<A b={<B x='x' />} />
<A b={<B y='x' />} />

// pass
<A b={<B x='y' />} />
<A b={<B x='y' other='any' />} />

LICENSE

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.4
    379
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.4
    379
  • 0.1.3
    0
  • 0.1.2
    0
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i @traveloka/prop-types

Weekly Downloads

379

Version

0.1.4

License

MIT

Unpacked Size

4.92 kB

Total Files

3

Last publish

Collaborators

  • angga
  • district-engineering
  • oryza
  • traveloka-engineering
  • raibima.putra
  • tools.infra
  • hansen.wijaya
  • imam_tvlk