react-prop-types

WebJar for react-prop-types

License

License

MIT
Categories

Categories

Github Development Tools Version Controls React User Interface Web Frameworks
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

github-com-react-bootstrap-react-prop-types
Last Version

Last Version

0.4.0
Release Date

Release Date

Type

Type

jar
Description

Description

react-prop-types
WebJar for react-prop-types
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/react-bootstrap/react-prop-types

Download github-com-react-bootstrap-react-prop-types

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/github-com-react-bootstrap-react-prop-types/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>github-com-react-bootstrap-react-prop-types</artifactId>
    <version>0.4.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-react-bootstrap-react-prop-types/
implementation 'org.webjars.npm:github-com-react-bootstrap-react-prop-types:0.4.0'
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-react-bootstrap-react-prop-types/
implementation ("org.webjars.npm:github-com-react-bootstrap-react-prop-types:0.4.0")
'org.webjars.npm:github-com-react-bootstrap-react-prop-types:jar:0.4.0'
<dependency org="org.webjars.npm" name="github-com-react-bootstrap-react-prop-types" rev="0.4.0">
  <artifact name="github-com-react-bootstrap-react-prop-types" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='github-com-react-bootstrap-react-prop-types', version='0.4.0')
)
libraryDependencies += "org.webjars.npm" % "github-com-react-bootstrap-react-prop-types" % "0.4.0"
[org.webjars.npm/github-com-react-bootstrap-react-prop-types "0.4.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : warning jar [3.0.0,4)

Project Modules

There are no modules declared in this project.

DEPRECATED!!!!!!

USE https://github.com/react-bootstrap/prop-types-extra

(it's the same thing)

react-prop-types Travis npm

Additional PropTypes for React.

Usage

import elementType from 'react-prop-types/lib/elementType';
// or
import { elementType } from 'react-prop-types';

const propTypes = {
  someProp: elementType,
};

If you want to minimize bundle size, import only the validators you use via:

import elementType from 'react-prop-types/lib/elementType'

Guide

Installation

$ npm i -S react
$ npm i -S react-prop-types

all(...validators)

This validator checks that all of the provided validators pass.

const propTypes = {
  vertical:  React.PropTypes.bool.isRequired,

  block: all(
    React.PropTypes.bool.isRequired,
    ({ block, vertical }) => (
      block && !vertical ?
        new Error('`block` requires `vertical` to be set to have any effect') :
        null
    ),
  ),
};

The provided validators will be validated in order, stopping on the first failure. The combined validator will succeed only if all provided validators succeed.

As in the example, this can be used to make a type assertion along with additional semantic assertions.

componentOrElement

Checks that the value is a ReactComponent or a DOMElement.

const propTypes = {
  container: componentOrElement,
  requiredContainer: componentOrElement.isRequired,
};

This ensures that the value is of the right type to pass to ReactDOM.findDOMNode(), for cases where you need a DOM node.

deprecated(validator, reason)

This validator will log a deprecation warning if the value is present.

const propTypes = {
  collapsable: deprecated(React.PropTypes.bool, 'Use `collapsible` instead.'),
};

If the collapsable prop above is specified, this validator will log the warning:

The prop `collapsable` of `MyComponent` is deprecated. Use `collapsible` instead.

This validator warns instead of failing on invalid values, and will still call the underlying validator if the deprecated value is present.

This validator will only warn once on each deprecation. To clear the cache of warned messages, such as for clearing state between test cases intended to fail on deprecation warnings, call deprecated._resetWarned().

elementType

Checks that the value is a React element type. This can be either a string (for DOM elements) or a ReactClass (for composite components).

const propTypes = {
  Component: elementType.isRequired,
};

This ensures that the value of is the right type for creating a ReactElement, such as with <Component {...props} />.

isRequiredForA11y(validator)

This validator checks that the value required for accessibility are present.

const propTypes = {
  id: isRequiredForA11y(React.PropTypes.string),
};

If the id prop above is not specified, the validator will fail with:

The prop `id` is required to make `MyComponent` accessible for users of assistive technologies such as screen readers.

org.webjars.npm

react-bootstrap

The popular front-end framework, rebuilt with React

Versions

Version
0.4.0