fix safe textarea

This commit is contained in:
xmcp
2020-01-06 18:17:40 +08:00
parent 11b1f9079b
commit 436ec949cb

View File

@@ -57,7 +57,7 @@ export class SafeTextarea extends Component {
constructor(props) {
super(props);
this.state={
text: window.TEXTAREA_BACKUP[props.id]||'',
text: '',
};
this.on_change_bound=this.on_change.bind(this);
this.on_keydown_bound=this.on_keydown.bind(this);
@@ -68,6 +68,12 @@ export class SafeTextarea extends Component {
this.submit_callback=props.on_submit||(()=>{});
}
componentDidMount() {
this.setState({
text: window.TEXTAREA_BACKUP[this.props.id]||''
});
}
componentWillUnmount() {
window.TEXTAREA_BACKUP[this.props.id]=this.state.text;
this.change_callback(this.state.text);