React: Expected an assignment or function call and instead saw an expression

前端 未结 8 1394
一个人的身影
一个人的身影 2020-11-27 05:40

I am trying to fix this lint error at line const def = (props) => { in following sample code.

const propTypes = {
prop1: PropTypes.string,
pr         


        
8条回答
  •  日久生厌
    2020-11-27 06:04

    In my case the problem was the line with default instructions in switch block:

      handlePageChange = ({ btnType}) => {
        let { page } = this.state;
        switch (btnType) {
          case 'next':
            this.updatePage(page + 1);
            break;
          case 'prev':
            this.updatePage(page - 1);
            break;
          default: null;
        } 
      }
    

    Instead of

    default: null;
    

    The line

    default: ;
    

    worked for me.

提交回复
热议问题