expected assignment or function call: no-unused-expressions ReactJS

前端 未结 14 827
挽巷
挽巷 2020-12-07 16:26
class Game extends Component 
{
  constructor() 
  {
    super()
    this.state = {
      speed: 0
    }
    //firebaseInit()
  }
  render()
  {
    return 
    (
           


        
14条回答
  •  甜味超标
    2020-12-07 17:16

    In my case, I got the error on the setState line:

    increment(){
      this.setState(state => {
        count: state.count + 1
      });
    }
    

    I changed it to this, now it works

    increment(){
      this.setState(state => {
        const count = state.count + 1
    
        return {
          count
        };
      });
    }
    

提交回复
热议问题