mattermost-mobile/app/components/formatted_date.js
Harrison Healey 96da38ed14 RN-345 Optimizing channel switching and general improvements (#914)
* Reduced re-renders of Channel screen

* Switched some components to be PureComponents

* Stopped waiting for drawer to close to switch channels

* Fixed post list being stuck loading

* Fixed incorrectly removed ref

* Removed loader from channel post list

* Removed unused prop

* Re-added ChannelDrawer.swiperIndex

* Changed ChannelPostTextbox to only require a single draft

* Re-enable InteractionManager on ChannelDrawer

* Fixed ChannelDrawer.joinChannel and removed duplicated code

* Moved getting device dimensions into render method

* Switched ChannelsList to be a PureComponent
2017-09-18 17:39:21 -03:00

37 lines
950 B
JavaScript

// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import {injectIntl, intlShape} from 'react-intl';
import {Text} from 'react-native';
class FormattedDate extends React.PureComponent {
static propTypes = {
intl: intlShape.isRequired,
value: PropTypes.any.isRequired,
format: PropTypes.string,
children: PropTypes.func
};
render() {
const {
intl,
value,
children,
...props
} = this.props;
Reflect.deleteProperty(props, 'format');
const formattedDate = intl.formatDate(value, this.props);
if (typeof children === 'function') {
return children(formattedDate);
}
return <Text {...props}>{formattedDate}</Text>;
}
}
export default injectIntl(FormattedDate);