소스 검색

Use fat arrow syntax

Andrew Swistak 6 년 전
부모
커밋
38dc454f7e
1개의 변경된 파일2개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 4
      app/javascript/packs/react-app/components/test_component.jsx

+ 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});