# HG changeset patch # User ymh # Date 1544050345 -3600 # Node ID d19ba6045e8243489deba60444dba3bed0c941a7 # Parent 99e342f9fb0cb1c36267d9d3df7165d1245e5d17 Optimize code a little bit. Get rid of very expensive and useless clone operation diff -r 99e342f9fb0c -r d19ba6045e82 client/src/components/NoteInput.js --- a/client/src/components/NoteInput.js Wed Dec 05 19:00:08 2018 +0100 +++ b/client/src/components/NoteInput.js Wed Dec 05 23:52:25 2018 +0100 @@ -20,8 +20,12 @@ } onEditorChange = (e) => { + let text = ''; + if(this.editor) { + text = this.editor.asPlain(); + } this.setState({ - buttonDisabled: e.value.document === 0, + buttonDisabled: text.length === 0, startedAt: e.startedAt, finishedAt: e.finishedAt }); diff -r 99e342f9fb0c -r d19ba6045e82 client/src/components/SlateEditor/index.js --- a/client/src/components/SlateEditor/index.js Wed Dec 05 19:00:08 2018 +0100 +++ b/client/src/components/SlateEditor/index.js Wed Dec 05 23:52:25 2018 +0100 @@ -4,7 +4,6 @@ import React from 'react'; import { withNamespaces } from 'react-i18next'; import { connect } from 'react-redux'; -import * as R from 'ramda'; import HtmlSerializer from './HtmlSerializer'; import { now } from '../../utils'; import Toolbar from './Toolbar'; @@ -55,8 +54,6 @@ onChange = ({value, operations}) => { - const oldState = R.clone(this.state); - const newState = { value }; @@ -75,7 +72,7 @@ this.setState(newState, () => { if (typeof this.props.onChange === 'function') { - this.props.onChange(R.clone(this.state), oldState, {value, operations}); + this.props.onChange(this.state, {value, operations}); } }) }