@reaktivo/spy-on-prop-types

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/reaktivo/spy-on-prop-types/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/@reaktivo/spy-on-prop-types.svg?style=flat)](https://www.npmjs.com/packa

Usage no npm install needed!

<script type="module">
  import reaktivoSpyOnPropTypes from 'https://cdn.skypack.dev/@reaktivo/spy-on-prop-types';
</script>

README

spy-on-prop-types

GitHub license npm version Coverage Status CircleCI Status

spy-on-prop-types is a small library that allows you to spy on your propTypes definitions.

Installation

npm install @reaktivo/spy-on-prop-types

Usage

You should first start by registering the library so it can spy on your propTypes definitions

import "spy-on-prop-types/register";

After that, you will be able to access your propTypes passed arguments by accessing the definition and the required property of a propType.

MyComponent.propTypes = {
  options: PropTypes.oneOf(["a", "b", "c"]).isRequired
};

console.log(MyComponent.propTypes.options);

/*
{
  definition: ["a", "b", "c"],
  required: true,
  type: 'oneOf',
}
*/

License

spy-on-prop-types is open source software licensed as MIT.