From c2b0b3255e7557e279d5ea6d547be8280b2abd7f Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Mon, 26 Nov 2018 20:27:48 -0300 Subject: [PATCH] Fix edit post (#2379) * Fix edit post * Fix other references to TextInputWithLocalizedPlaceholder --- app/components/edit_channel_info/index.js | 8 ++++---- .../text_input_with_localized_placeholder.js | 14 ++++++++------ app/screens/edit_post/edit_post.js | 2 +- app/screens/mfa/mfa.js | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/components/edit_channel_info/index.js b/app/components/edit_channel_info/index.js index f0ca0dd7a..1750a8eb4 100644 --- a/app/components/edit_channel_info/index.js +++ b/app/components/edit_channel_info/index.js @@ -55,18 +55,18 @@ export default class EditChannelInfo extends PureComponent { blur = () => { if (this.nameInput) { - this.nameInput.refs.wrappedInstance.blur(); + this.nameInput.blur(); } // TODO: uncomment below once the channel URL field is added // if (this.urlInput) { - // this.urlInput.refs.wrappedInstance.blur(); + // this.urlInput.blur(); // } if (this.purposeInput) { - this.purposeInput.refs.wrappedInstance.blur(); + this.purposeInput.blur(); } if (this.headerInput) { - this.headerInput.refs.wrappedInstance.blur(); + this.headerInput.blur(); } if (this.scroll) { this.scroll.scrollToPosition(0, 0, true); diff --git a/app/components/text_input_with_localized_placeholder.js b/app/components/text_input_with_localized_placeholder.js index 9b325b416..431ade37c 100644 --- a/app/components/text_input_with_localized_placeholder.js +++ b/app/components/text_input_with_localized_placeholder.js @@ -3,13 +3,16 @@ import React, {PureComponent} from 'react'; import PropTypes from 'prop-types'; -import {injectIntl, intlShape} from 'react-intl'; +import {intlShape} from 'react-intl'; import {TextInput} from 'react-native'; -class TextInputWithLocalizedPlaceholder extends PureComponent { +export default class TextInputWithLocalizedPlaceholder extends PureComponent { static propTypes = { ...TextInput.propTypes, placeholder: PropTypes.object.isRequired, + }; + + static contextTypes = { intl: intlShape.isRequired, }; @@ -22,10 +25,11 @@ class TextInputWithLocalizedPlaceholder extends PureComponent { }; render() { - const {intl, placeholder, ...otherProps} = this.props; + const {formatMessage} = this.context.intl; + const {placeholder, ...otherProps} = this.props; let placeholderString = ''; if (placeholder.id) { - placeholderString = intl.formatMessage(placeholder); + placeholderString = formatMessage(placeholder); } return ( @@ -38,5 +42,3 @@ class TextInputWithLocalizedPlaceholder extends PureComponent { ); } } - -export default injectIntl(TextInputWithLocalizedPlaceholder, {withRef: true}); diff --git a/app/screens/edit_post/edit_post.js b/app/screens/edit_post/edit_post.js index 69b670bdd..e5de6b821 100644 --- a/app/screens/edit_post/edit_post.js +++ b/app/screens/edit_post/edit_post.js @@ -108,7 +108,7 @@ export default class EditPost extends PureComponent { }; focus = () => { - this.messageInput.refs.wrappedInstance.focus(); + this.messageInput.focus(); }; messageRef = (ref) => { diff --git a/app/screens/mfa/mfa.js b/app/screens/mfa/mfa.js index be1f21f81..ec0c363ca 100644 --- a/app/screens/mfa/mfa.js +++ b/app/screens/mfa/mfa.js @@ -81,7 +81,7 @@ export default class Mfa extends PureComponent { }; blur = () => { - this.textInput.refs.wrappedInstance.blur(); + this.textInput.blur(); }; submit = preventDoubleTap(() => {