From 436ec949cbf933198663170664dbc449d64bd0ba Mon Sep 17 00:00:00 2001 From: xmcp Date: Mon, 6 Jan 2020 18:17:40 +0800 Subject: [PATCH] fix safe textarea --- src/Common.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Common.js b/src/Common.js index 868fd3c..e9611c4 100644 --- a/src/Common.js +++ b/src/Common.js @@ -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);