force clear & set value in input on mount / unmount

This commit is contained in:
igoradamenko
2018-05-18 22:35:58 +03:00
parent 783ae26f78
commit d9d423c055
+6 -1
View File
@@ -29,7 +29,7 @@ export default class Input extends Component {
}
componentDidMount() {
const { mods = {} } = this.props;
const { mods = {}, value } = this.props;
if (this.props.autoFocus) {
this.fieldNode.focus();
@@ -38,6 +38,7 @@ export default class Input extends Component {
if (mods.mode !== 'edit') {
this.fieldNode.value = '';
} else {
this.fieldNode.value = value;
this.autoResize();
}
@@ -46,6 +47,10 @@ export default class Input extends Component {
});
}
componentWillUnmount() {
this.fieldNode.value = '';
}
shouldComponentUpdate(nextProps) {
return nextProps.id !== this.props.id
|| nextProps.pid !== this.props.pid