Skip to content

Instantly share code, notes, and snippets.

@mreigen
Created June 1, 2020 17:01
Show Gist options
  • Save mreigen/5a99627da3059de16013a1586ba4265f to your computer and use it in GitHub Desktop.
Save mreigen/5a99627da3059de16013a1586ba4265f to your computer and use it in GitHub Desktop.
old code to auto save text using debounce
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