Skip to content

Commit

Permalink
Fix components changing their own props
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Aug 6, 2019
1 parent d6600a6 commit 43d5616
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/Editor.js
Expand Up @@ -18,6 +18,7 @@ export default class Editor extends Component {
* @param {MutationObserver} observer
*/
handleMutation(mutationList, observer) {
let rebuildDOM = false;
const data = this.#DOMData;
for (const mutation of mutationList) {
const { target, type } = mutation;
Expand Down Expand Up @@ -75,12 +76,13 @@ export default class Editor extends Component {
obj[key] = undefined;
});
Object.assign(obj, JSON.parse(target.dataset.json));
rebuildDOM = true;
}
break;
}
}

this.props.onChange(data.get(this), false);
this.props.onChange(data.get(this), rebuildDOM);
}

observeNode(node) {
Expand Down
2 changes: 0 additions & 2 deletions src/components/AsideList.js
Expand Up @@ -9,8 +9,6 @@ export default class AsideList extends Component {
writeMode: false,
data: JSON.stringify(data),
});

Object.assign(this.props, data);
}

render() {
Expand Down
2 changes: 0 additions & 2 deletions src/components/NewsletterArticle.js
Expand Up @@ -52,8 +52,6 @@ export default class NewsletterArticle extends Component {
writeMode: false,
data: JSON.stringify(data),
});

Object.assign(this.props, data);
}

render() {
Expand Down

0 comments on commit 43d5616

Please sign in to comment.