Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue, that would cause tinymce to be updated too often #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/components/TinyMCE.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { findDOMNode } from 'react-dom';
import isEqual from 'lodash/lang/isEqual';
import clone from 'lodash/lang/clone';
import cloneDeep from 'lodash/lang/cloneDeep';
import uuid from '../helpers/uuid';
import ucFirst from '../helpers/ucFirst';

Expand Down Expand Up @@ -51,7 +51,6 @@ const TinyMCE = React.createClass({
},

componentDidMount() {
const config = clone(this.props.config);
this._init(config);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be this.props.config

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to use cloneDeep here?

},

Expand Down Expand Up @@ -91,11 +90,15 @@ const TinyMCE = React.createClass({
);
},

_init(config, content) {
_init(configProp, content) {
if (this._isInit) {
this._remove();
}

// Clone the config prop to prevent modifications by TinyMCE, which
// would cause the react component to be updated incorrectly.
var config = cloneDeep(configProp);

// hide the textarea that is me so that no one sees it
findDOMNode(this).style.hidden = 'hidden';

Expand Down