Skip to content

Commit

Permalink
fix: DateTimeInput causing issues in production
Browse files Browse the repository at this point in the history
When this library is used in a project that runs rollup, the
DateTimeInput causes issues on production environments. It is a known
issue in rollup, see arqex/react-datetime#843.

Added temporary workaround to prevent issues in production environments
with DateTimeInput.
  • Loading branch information
Gido Manders committed Mar 16, 2023
1 parent c4ad29c commit 54879eb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/form/DateTimeInput/DateTimeInput.tsx
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { FormGroup, Input, InputGroup, Label } from 'reactstrap';
import Datetime from 'react-datetime';
import ReactDatetimeClass from 'react-datetime';
import { constant, get, uniqueId } from 'lodash';
import moment, { Moment } from 'moment';
import classNames from 'classnames';
Expand All @@ -21,6 +21,10 @@ import { Button } from '../../core/Button/Button';
import { Icon } from '../../core/Icon';
import { MomentInput } from 'moment/moment';

// istanbul ignore next
// @ts-expect-error This is only a temporary hacky fix for rollup related issues https://github.com/arqex/react-datetime/issues/843
const Datetime = ReactDatetimeClass.default ?? ReactDatetimeClass;

/**
* Callback which returns whether a date is selectable.
*/
Expand Down Expand Up @@ -151,7 +155,6 @@ export function DateTimeInput(props: Props) {
) : null}
<Datetime
inputProps={{
// @ts-expect-error Our input prop will have a mask because it is a `MaskedInput`.
mask: formatToMask(dateFormat, timeFormat),
placeholder,
invalid: valid === false,
Expand Down

0 comments on commit 54879eb

Please sign in to comment.