diff --git a/docs/guides/saving-to-a-database.md b/docs/guides/saving-to-a-database.md index 6ba5c97ef..7e8516cb2 100644 --- a/docs/guides/saving-to-a-database.md +++ b/docs/guides/saving-to-a-database.md @@ -123,16 +123,17 @@ class App extends React.Component { constructor(props) { super(props) this.state = { - // Update the initial value to be pulled from Local Storage. state: Plain.deserialize(localStorage.getItem('content')) } } render() { + // Add the `onDocumentChange` handler to the editor. return ( this.onChange(state)} + onDocumentChange={state => this.onDocumentChange(document, state)} /> ) } @@ -141,6 +142,7 @@ class App extends React.Component { this.setState({ state }) } + // Pull the saving logic out into the `onDocumentChange` handler. onDocumentChange(document, state) { const string = Plain.serialize(state) localStorage.setItem('content', string)