# react-moment-proptypes

> React proptype for moment module

Latest version **1.8.1** (published 2021-03-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-moment-proptypes
pnpm add react-moment-proptypes
yarn add react-moment-proptypes
bun add react-moment-proptypes
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.8.1 |
| Published | 2021-03-24 |
| First published | 2015-06-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 50.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 49 |
| Author | Caleb Morris |
| Maintainers | calebmorris, caleb.morris |
| Keywords | moment, react, props, proptypes |

## Links

- npm: https://www.npmjs.com/package/react-moment-proptypes
- Repository: https://github.com/CalebMorris/react-moment-proptypes
- Homepage: https://github.com/CalebMorris/react-moment-proptypes#readme
- Issues: https://github.com/CalebMorris/react-moment-proptypes/issues
- npm.io page: https://npm.io/package/react-moment-proptypes

## Dependencies (1)

- [moment](https://npm.io/package/moment.md) >=1.6.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.8.1 (latest) — 2021-03-24
- 1.8.0 — 2021-03-04
- 1.7.0 — 2019-08-15
- 1.6.0 — 2018-06-09
- 1.5.0 — 2017-07-03
- 1.4.0 — 2017-04-02
- 1.3.0 — 2017-02-11
- 1.2.1 — 2016-12-10
- 1.2.0 — 2016-07-02
- 1.1.2 — 2016-06-17
- 1.1.1 — 2016-01-16
- 1.1.0 — 2016-01-15
- 1.0.0 — 2015-07-30
- 0.3.0 — 2015-07-24
- 0.2.0 — 2015-07-23
- … 5 more at https://npm.io/package/react-moment-proptypes/versions

## README

# react-moment-proptypes

[![Build
Status](https://travis-ci.org/CalebMorris/react-moment-proptypes.svg?branch=master)](https://travis-ci.org/CalebMorris/react-moment-proptypes)
[![Coverage Status](https://coveralls.io/repos/CalebMorris/react-moment-proptypes/badge.svg?branch=master&service=github)](https://coveralls.io/github/CalebMorris/react-moment-proptypes?branch=master)

A React Proptype Validator to check if passed prop is a moment.js construct

# Example

``` jsx
var momentPropTypes = require('react-moment-proptypes');

var TestClass = React.createClass({
  propTypes : {
    dateThing : momentPropTypes.momentObj,
    dateThingWithPredicate : momentPropTypes.momentObj.withPredicate(
      function isUTC(momentObject) {
        return momentObject.isUTC();
      }
    ),
    stringThing : momentPropTypes.momentString,
    durationThing: momentPropTypes.momentDurationObj,
  },

  render : function() {
    return null
  },
});

// Class Use
<TestClass dateThing={moment()}
           dateThingWithPredicate={moment.utc()}
           stringThing={'12-12-2014'}
           durationThing={moment.duration(3, 'hours')}/>

```

# Moment Configuration

## createFromInputFallback
Moment provides a `moment.createFromInputFallback` method you can define to create additional parsing rules.

With some versions of moment you may receive the following console warning:
```
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: not a date, _f: undefined, _strict: undefined, _locale: [object Object]
Error
    at [... stack trace]
```
Example implementations can be found at the [given documentation link](http://momentjs.com/guides/#/warnings/js-date/).


# Tests

Tests were approached with `enzyme` and React's test utility renderer

- `npm test` for running unit and integration tests
- `npm run coverage` for current test coverage

## Moment Versions

- `npm run test-all` to test against tested moment version (1.6.0, 1.7.0, current)

If there is a desire for varying moment legacy support I'm willing to add it, but will stick to YAGNI until then.

---
_Source: https://npm.io/package/react-moment-proptypes · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
