• home > webfront > ECMAS > react >

    react:Uncaught TypeError: Cannot read property

    Author:[email protected] Date:

    Uncaught TypeError: Cannot read property伙伴把我的demo重新写了一遍,然后,发现,这个错误。俺也是找了半天。尼玛属性咋就不存在呢…这个问题一般都是没有默认返回造成的。比如前面的计算器项目,注释defualt 选项,然后就会复现

    伙伴把我的demo重新写了一遍,然后,发现,这个错误。

    俺也是找了半天。尼玛属性咋就不存在呢…………

    Uncaught TypeError: Cannot read property 'value' of undefined

        at mapStateToProps ((index):42)

        at Connect.configureFinalMapState (connect.js?b19a*:155)

        at Connect.computeStateProps (connect.js?b19a*:142)

        at Connect.updateStatePropsIfNeeded (connect.js?b19a*:204)

        at Connect.render (connect.js?b19a*:340)

        at ReactCompositeComponent.js?19b3****:793

        at measureLifeCyclePerf (ReactCompositeComponent.js?19b3****:74)

        at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js?19b3****:792)

        at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js?19b3****:819)

        at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.

    这个问题一般都是没有默认返回造成的。比如前面的计算器项目,注释defualt 选项,然后就会复现这个错误


    const reducer=(state=states,action)=>{
      switch (action.type){
        case 'clear':
          return{
            ...state,
            value:0
          };
        case 'equal':
          return{
            ...state,
            value:eval(state.value)
          };
        case 'addItem':
          return{
            ...state,
            value:state.value===0?action.text:state.value+action.text
          };
        default:
          return state;
      }
    };



    转载本站文章《react:Uncaught TypeError: Cannot read property 》,
    请注明出处:https://www.zhoulujun.cn/html/webfront/ECMAScript/jsBase/2017_0315_7962.html