From 6bc3e7fcf106c71f9527c561cdcf789c2c375b15 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Mon, 14 Aug 2017 12:03:14 +0900 Subject: [PATCH] [eslint] react/no-direct-mutation-state --- .eslintrc | 1 - browser/main/Detail/SnippetNoteDetail.js | 6 +++--- browser/main/Main.js | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.eslintrc b/.eslintrc index 33eac81e..9177344c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -10,7 +10,6 @@ "react/prop-types": 0, "react/no-string-refs": 0, "react/no-find-dom-node": "warn", - "react/no-direct-mutation-state": "warn", "react/no-render-return-value": "warn", "react/no-deprecated": "warn" } diff --git a/browser/main/Detail/SnippetNoteDetail.js b/browser/main/Detail/SnippetNoteDetail.js index d6647f99..05efce45 100644 --- a/browser/main/Detail/SnippetNoteDetail.js +++ b/browser/main/Detail/SnippetNoteDetail.js @@ -271,7 +271,7 @@ class SnippetNoteDetail extends React.Component { let syntax = CodeMirror.findModeByFileName(name.trim()) let mode = syntax != null ? syntax.name : null if (mode != null) snippets[index].mode = mode - this.state.note.snippets = snippets + this.setState({note: Object.assign(this.state.note, {snippets: snippets})}) this.setState({ note: this.state.note @@ -284,7 +284,7 @@ class SnippetNoteDetail extends React.Component { return (e) => { let snippets = this.state.note.snippets.slice() snippets[index].mode = name - this.state.note.snippets = snippets + this.setState({note: Object.assign(this.state.note, {snippets: snippets})}) this.setState({ note: this.state.note @@ -298,7 +298,7 @@ class SnippetNoteDetail extends React.Component { return (e) => { let snippets = this.state.note.snippets.slice() snippets[index].content = this.refs['code-' + index].value - this.state.note.snippets = snippets + this.setState({note: Object.assign(this.state.note, {snippets: snippets})}) this.setState({ note: this.state.note }, () => { diff --git a/browser/main/Main.js b/browser/main/Main.js index 7557d2ae..522ddca3 100644 --- a/browser/main/Main.js +++ b/browser/main/Main.js @@ -172,8 +172,8 @@ class Main extends React.Component { } hideLeftLists (noteDetail, noteList, mainBody) { - this.state.noteDetailWidth = noteDetail.style.left - this.state.mainBodyWidth = mainBody.style.left + this.setState({noteDetail: noteDetail.style.left}) + this.setState({mainBody: mainBody.style.left}) noteDetail.style.left = '0px' mainBody.style.left = '0px' noteList.style.display = 'none'