Date: Tue, 8 Oct 2019 19:26:01 +0800
Subject: [PATCH 04/12] refactor
---
.eslintrc.js | 2 ++
examples/simple.js | 19 ++++++++------
package.json | 1 -
src/Align.tsx | 46 +++++++++++++++++++++++++-------
src/hooks/useBuffer.tsx | 30 +++++++++++++++++++++
src/util.ts | 58 ++++++++++++++++++++---------------------
6 files changed, 108 insertions(+), 48 deletions(-)
create mode 100644 src/hooks/useBuffer.tsx
diff --git a/.eslintrc.js b/.eslintrc.js
index f21cd5a..dc20b71 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -5,5 +5,7 @@ module.exports = {
rules: {
...base.rules,
'react/no-find-dom-node': 0,
+ 'jsx-a11y/label-has-associated-control': 0,
+ 'jsx-a11y/label-has-for': 0,
},
};
diff --git a/examples/simple.js b/examples/simple.js
index 3e47685..3df36ec 100644
--- a/examples/simple.js
+++ b/examples/simple.js
@@ -48,15 +48,15 @@ class Test extends Component {
};
toggleMonitor = () => {
- this.setState({
- monitor: !this.state.monitor,
- });
+ this.setState(({ monitor }) => ({
+ monitor: !monitor,
+ }));
};
toggleRandom = () => {
- this.setState({
- random: !this.state.random,
- });
+ this.setState(({ random }) => ({
+ random: !random,
+ }));
};
forceAlign = () => {
@@ -73,7 +73,9 @@ class Test extends Component {
}}
>
-
+