Browse Source

Use fat arrow syntax

Andrew Swistak 6 năm trước cách đây
mục cha
commit
38dc454f7e

+ 2 - 4
app/javascript/packs/react-app/components/test_component.jsx

@@ -4,13 +4,11 @@ class TestComponent extends React.Component {
   constructor(props) {
     super(props);
     this.state = {text: ''};
-
-    this.onChange = this.onChange.bind(this);
   }
 
-  onChange(e) {
+  onChange = e => {
     this.updateText(e.target.value);
-  }
+  };
 
   updateText = text => {
     this.setState({text: text});