Optimize code a little bit. Get rid of very expensive and useless clone operation
--- 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
});
--- 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});
}
})
}