Warning: Unreachable code , using Reactjs

后端 未结 2 968
予麋鹿
予麋鹿 2021-01-24 21:51

I am using ReactJs. I have two Components,PrescriptionIndex and PrescriptionNew, integrating one with another.

This is my first component \'PrescriptionNew\'

2条回答
  •  太阳男子
    2021-01-24 22:26

    Your code is currently

    if (X)
      return A
    else
      return B
    return C
    

    Of course C is unreachable here. I think you meant to drop the else case (B) where you currently are returning null, and return C instead of it.

    if (this.props.prescriptions.prescriptions !== undefined) {
      return this.props.prescriptions.prescriptions.map(function(data){
        return (
          
    prescription
    ); }); } else { // return null; <== remove this return (
    ) }

提交回复
热议问题