如何在React组件上设置Timout

I have a component which fetch data from backend. Here I have already added loading while the component fetch on data from backend. But the problem is if there is no data available there it still keeps on showing that loading. Instead I want to show something like There is nothing In here Text on screen if loading is complete and no data is available there. I want to know how to implement this any help would be great.

这是我的代码
class FootStep extends React.Component {
  componentDidMount() {
    this.props.getFootstep();
  }
  render() {
    const { loaded, loading, error, data } = this.props.footstep.data;
    console.log("footstepContainer props", this.props);
    if (loaded) {
      return <Footstep data={data} />;
    } else return <p>loading</p>;
  }
}
评论