0

我在我的组件中使用 inView。在帖子加载之前,用户会看到骨架。但是当我按下删除按钮时,骨架会出现并消失。我可以在按下删除按钮时停止这种快速出现吗?

class MyPosts extends Component {
  deleteItem = (key) => {
    this.props.deleteItem(key);
  };

  render() {
    const { myPosts, classes } = this.props;

    let posts = myPosts.map((item) => {
      return (
        <InView threshold={0}>
          {({ ref, inView }) => (
            <div  ref={ref} inView={inView}>
              {inView ? (
                <Card>                  
                  <Typography >
                    {item.post}
                  </Typography>                 
                  <Button                   
                   onClick={() => this.deleteItem(item.key)}
                  >
                    Done
                  </Button>
                </Card>
              ) : (
                <Skeleton />
              )}
            </div>
          )}
        </InView>
      );
    });

    return <div>{posts}</div>;
  }
}
4

0 回答 0