2017-02-23 43 views
-1

我試圖將反應組件集成到我的React項目中。與一飲而盡transpiling當我在網上得到一個錯誤onClick =() => {onClick =()=> {拋出吞吐量意外的令牌錯誤

JS /擴展-animation.js:意外令牌(14:16)

我使用與babelfy杯和"presets": ["react", "es2016"]

想法?

import React, {Component} from 'react'; 

    const animationStyle = { 
     transition: 'width 0.75s cubic-bezier(0.000, 0.795, 0.000, 1.000)' 
    }; 

    const makeExpanding = (Target) => { 
     return class extends Component { 
      constructor(props) { 
       super(props); 
       this.state = {isOpen: false}; 
      } 

      onClick =() => { 
       this.setState({isOpen: !this.state.isOpen}); 
      }; 

      render() { 
       return (
        <Target {...this.props} 
          isOpen={this.state.isOpen} 
          onClick={this.onClick} 
          additionalStyles={{text: animationStyle, frame: animationStyle}}/> 
       ); 
      } 
     } 
    }; 

    export default makeExpanding; 
+1

這是不正確類語法,嘗試'的onclick(){... funcCode ...} '沒有結束分號';' –

+0

如果你拿出那個函數它仍然抱怨? –

+0

不相關,但標題'onClick =()=> {在gulp中拋出意外的標記錯誤可能是無效格式在SO([我怎麼問一個好問題?](http://stackoverflow.com/help/how -to-問)) –

回答