Created
June 1, 2020 17:01
-
-
Save mreigen/5a99627da3059de16013a1586ba4265f to your computer and use it in GitHub Desktop.
old code to auto save text using debounce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { debounce } from "lodash"; | |
import RichText from "../controls/rich_text"; | |
... | |
class TextQuestion extends React.Component { | |
constructor(props) { | |
super(props); | |
this.update = debounce(this._update.bind(this), 500); | |
} | |
_update(text) { | |
this.setState({ text }); | |
callAPIToSaveText({ answer: text }); | |
} | |
... | |
render() { | |
... | |
<RichText.NoToolbar editorClass="small" value={this.state.text} onChange={this.update} /> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment