Package Exports
- svg-prop-types
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 (svg-prop-types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
svg-prop-types
Custom SVG prop types for React.
SVG content type:
SVGLength
: ensure that the length used is compatible with a SVG length (see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#Length)
...
SVG and HTML attributes sets:
shape
contains common shapes attributesconditionalProcessing
core
contains core HTML attributesgraphicalEvent
contains graphical events attributesdocumentEvent
contains document events attributespresentation
contains presentational attributes
...
SVG elements:
SVG
circle
line
...
Usage
import React, { Component } from 'react';
import { circle as circlePropType } from 'svg-prop-types';
class Circle extends Component {
static propTypes = circlePropType;
render() {
return (
<circle
{...this.props}
/>
);
}
}
export default Circle;
Production
Build pipeline is borrowed from https://github.com/airbnb/prop-types
Since PropTypes are typically not included in production builds of React, this library’s functionality serves no useful purpose. As such, when the NODE_ENV environment variable is "production", instead of exporting the implementations of all these prop types, we export mock functions - in other words, something that ensures that no exceptions are thrown, but does no validation. When environment variables are inlined (via a browserify transform or webpack plugin), then tools like webpack or uglify are able to determine that only the mocks will be imported - and can avoid including the entire implementations in the final bundle that is sent to the browser. This allows for a much smaller ultimate file size, and faster in-browser performance, without sacrificing the benefits of PropTypes themselves.
Tests
Simply clone the repo, npm install, and run npm test