force clear & set value in input on mount / unmount
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user