Skip to content

Commit d23fa2f

Browse files
panda12530panyinan
andauthored
feat:添加shouldComponentUpdate方法 (#10)
Co-authored-by: panyinan <panyinan2@h-partners.com>
1 parent bfe0aca commit d23fa2f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/components/field/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@ export default class TextField extends PureComponent {
286286
this.onChangeText('');
287287
}
288288

289+
shouldComponentUpdate(nextProps) {
290+
if(this.props.value !== nextProps.value) {
291+
this.onChangeText(nextProps.value);
292+
}
293+
return true
294+
}
295+
289296
value() {
290297
let { text } = this.state;
291298
let { defaultValue } = this.props;

0 commit comments

Comments
 (0)