Skip to content

Commit

Permalink
Improve propTypes in ValueOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Apr 5, 2023
1 parent 2198221 commit c82d464
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 5 additions & 3 deletions test/ValueOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import { getISOLocalDateTime } from '@wojtekmaj/date-utils';

import { isValue } from './shared/propTypes';

import type { LooseValue } from './shared/types';

type ValueOptionsProps = {
Expand Down Expand Up @@ -117,9 +115,13 @@ export default function ValueOptions({
);
}

const isValue = PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]);

const isValueOrValueArray = PropTypes.oneOfType([isValue, PropTypes.arrayOf(isValue)]);

ValueOptions.propTypes = {
selectRange: PropTypes.bool,
setSelectRange: PropTypes.func.isRequired,
setValue: PropTypes.func.isRequired,
value: PropTypes.oneOfType([PropTypes.string, isValue]),
value: isValueOrValueArray,
};
6 changes: 0 additions & 6 deletions test/shared/propTypes.ts

This file was deleted.

0 comments on commit c82d464

Please sign in to comment.