Skip to content

Commit

Permalink
Merge pull request #11033 from rushatgabhane/rm-setNativeProps-composer
Browse files Browse the repository at this point in the history
Composer - Migrate setNativeProps to state
  • Loading branch information
luacmartins authored Sep 21, 2022
2 parents 23a8057 + ff402a4 commit 09ff150
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class ReportActionCompose extends React.Component {
end: props.comment.length,
},
maxLines: props.isSmallScreenWidth ? CONST.COMPOSER.MAX_LINES_SMALL_SCREEN : CONST.COMPOSER.MAX_LINES,
value: props.comment,
};
}

Expand Down Expand Up @@ -312,9 +313,6 @@ class ReportActionCompose extends React.Component {
addEmojiToTextBox(emoji) {
const newComment = this.comment.slice(0, this.state.selection.start)
+ emoji + this.comment.slice(this.state.selection.end, this.comment.length);
this.textInput.setNativeProps({
text: newComment,
});
this.setState(prevState => ({
selection: {
start: prevState.selection.start + emoji.length,
Expand Down Expand Up @@ -373,9 +371,9 @@ class ReportActionCompose extends React.Component {
* @param {String} newComment
*/
updateComment(newComment) {
this.textInput.setNativeProps({text: newComment});
this.setState({
isCommentEmpty: !!newComment.match(/^(\s|`)*$/),
value: newComment,
});

// Indicate that draft has been created.
Expand Down Expand Up @@ -628,7 +626,6 @@ class ReportActionCompose extends React.Component {
this.setState({isDraggingOver: false});
}}
style={[styles.textInputCompose, this.props.isComposerFullSize ? styles.textInputFullCompose : styles.flex4]}
defaultValue={this.props.comment}
maxLines={this.state.maxLines}
onFocus={() => this.setIsFocused(true)}
onBlur={() => this.setIsFocused(false)}
Expand All @@ -641,6 +638,7 @@ class ReportActionCompose extends React.Component {
isFullComposerAvailable={this.state.isFullComposerAvailable}
setIsFullComposerAvailable={this.setIsFullComposerAvailable}
isComposerFullSize={this.props.isComposerFullSize}
value={this.state.value}
/>
</View>
</>
Expand Down

0 comments on commit 09ff150

Please sign in to comment.