toggle-corp/react-store

View on GitHub
components/View/FormattedDate/index.js

Summary

Maintainability
A
0 mins
Test Coverage
import PropTypes from 'prop-types';
import React from 'react';
import { isTruthy } from '@togglecorp/fujs';

import FormattedDate from './FormattedDate';

const HackedFormattedDate = ({ value, ...otherProps }) => {
    if (isTruthy(value)) {
        return (
            <FormattedDate
                {...otherProps}
                date={value}
            />
        );
    }
    return (
        <FormattedDate
            {...otherProps}
        />
    );
};

HackedFormattedDate.propTypes = {
    value: PropTypes.oneOfType([
        PropTypes.number,
        PropTypes.string,
        PropTypes.instanceOf(Date),
    ]),
};
HackedFormattedDate.defaultProps = {
    value: undefined,
};
HackedFormattedDate.format = FormattedDate.format;

export default HackedFormattedDate;