React : How to Show Message if there is no records

前端 未结 5 1078
耶瑟儿~
耶瑟儿~ 2021-01-16 18:35

I am working on project in ReactJS, I am fetching data from server through API. I did some search filtration, I want to display message if there is no records available? I a

5条回答
  •  不知归路
    2021-01-16 19:12

    You can add your message as another conditional wherever you'd like:

    {this.state.filtered.length === 0 && (
      
    Your Message
    )}

    Or if you're trying to add a message for getting no results at all, then:

    {this.state.allData.length === 0 && (
      
    Your Message
    )}

提交回复
热议问题