1.8.1 • Published 3 years ago

react-moment-proptypes v1.8.1

Weekly downloads
551,722
License
MIT
Repository
github
Last release
3 years ago

react-moment-proptypes

Build
Status Coverage Status

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

Example

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.

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.

leaf-react-datesjalali-support-react-dates@mygooder/react-dates@sophia-iot/library-components@chewcw/react-datetimepicker@chewcw/custom-datetimepickerlyrahealth-uicoreprebid-adpod-client@orbit-ui/react-date-picker@orbit-ui/react-date-range-pickerairbnb-react-dates@sproutsocial/react-dates@infinitebrahmanuniverse/nolb-react-mo@everything-registry/sub-chunk-2568front-affilate@skillx/react-dates@gaugebrasil/react-dateswm-react-datesu-datetimerange-pickertrucking-react-dates@telerion/react-datetimepickerreact-18-datestablet-react-datest2-core-react-componentstmx-react-datestradebasethinkpage-react-datesstreet-cars-coresimplepos-adminlte2-reactsuperdesk-planningstack-ui-componentsssc-formula2v47-react-dateswwc-react-dates@kai_zhang/react-itsb-calendarestimize-react-dates@kupibilet/react-dates@holokit/charts@ingoclaro/react-datesem-booking-airports@moctarm/react-dates-umai-react-v18@mooveit-team/react-ui@mateioprea/react-datesflight-search-calendar@mohsen_saremi/react-dates@mohsen_saremi/react-dates-muigauge-react-dates@navarik/react-dates@nds_core/nds@nfort/react-yearly-calendareig-react-dates@saddlebackchurch/react-cm-uih-react-dates@robbterr/react-advanced-datetimerange-pickerinputs-2-reacthicvoluptatedz-cubeemidates@ilya.sizov/react-datetimepicker@jayswain/react-datesengage-uihreact-dates22@payly/react-componentshusky-react-dateshumanyze-react-dates@slcloud/react-advanced-datetimerange-picker@estimize/react-dates@eqworks/extended-semantic-components@shobhitk/react-dates-latest@elbstack/react-dates@fmauneko/react-dates@swrve/calendar@tourstream/mph-components-lib@tanyagreen/adminlte-2-react@tombatossals/react-dates@telus-uds/components-webbackpack-ui@buffetjs/core@buffetjs/customblt-react-dates@bizarreaster/custom-dt-pickermy-component-092mwm-react-dates@beapi/dominicalcanvas-planner@danielstecki/react-datesarena-prop-types@appbaseio/reactivebase@appearhere/bloommoksa-form-components@availity/react-datesadporrobuffetjs@cloudflare/component-filter-barnode-red-contrib-chatbot-mission-control@cloudflare/component-time-period-picker@cloudhms/react-dates@cscenter/react-dates@tds/community-date-pickera0swa0swreact-dates
1.8.1

3 years ago

1.8.0

3 years ago

1.7.0

5 years ago

1.6.0

6 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.1

7 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago