Skip to content

Commit 351742b

Browse files
authored
TextField - fix unnecessary placeholder change (#1589)
1 parent e8efee9 commit 351742b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/components/textField/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import _ from 'lodash';
88
import PropTypes from 'prop-types';
99
import React from 'react';
1010
import {StyleSheet, Animated, TextInput as RNTextInput, Image as RNImage} from 'react-native';
11+
import memoize from 'memoize-one';
1112
import {Constants} from '../../helpers';
1213
import {Colors, Typography, Spacings} from '../../style';
1314
import BaseInput from '../baseInput';
@@ -274,7 +275,7 @@ export default class TextField extends BaseInput {
274275
}
275276
};
276277

277-
getPlaceholderText() {
278+
getPlaceholderText = memoize(() => {
278279
// HACK: passing whitespace instead of undefined. Issue fixed in RN56
279280
const {placeholder, helperText} = this.props;
280281
const text = this.shouldFakePlaceholder()
@@ -285,7 +286,7 @@ export default class TextField extends BaseInput {
285286
? helperText
286287
: this.getRequiredPlaceholder(placeholder);
287288
return text;
288-
}
289+
});
289290

290291
getStateColor(colorProp = {}) {
291292
const {focused} = this.state;

0 commit comments

Comments
 (0)