Files
mattermost-mobile/app/components/text_input_with_localized_placeholder.js
2018-09-20 19:05:41 -03:00

43 lines
1.1 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {injectIntl, intlShape} from 'react-intl';
import {TextInput} from 'react-native';
class TextInputWithLocalizedPlaceholder extends PureComponent {
static propTypes = {
...TextInput.propTypes,
placeholder: PropTypes.object.isRequired,
intl: intlShape.isRequired,
};
blur = () => {
this.refs.input.blur();
};
focus = () => {
this.refs.input.focus();
};
render() {
const {intl, placeholder, ...otherProps} = this.props;
let placeholderString = '';
if (placeholder.id) {
placeholderString = intl.formatMessage(placeholder);
}
return (
<TextInput
ref='input'
{...otherProps}
placeholder={placeholderString}
disableFullscreenUI={true}
/>
);
}
}
export default injectIntl(TextInputWithLocalizedPlaceholder, {withRef: true});