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 cfdc69c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/form/DateTimeInput/DateTimeInput.tsx
Original file line number Diff line number Diff line change
@@ -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,9 @@ import { Button } from '../../core/Button/Button';
import { Icon } from '../../core/Icon';
import { MomentInput } from 'moment/moment';

// @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 +154,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 cfdc69c

Please sign in to comment.