简体   繁体   English

如何在加载数据时在反应组件中加载微调器

[英]How to load spinner in react component while data is loading

I am trying to add a loading spinner using react hooks use state. I want to what is the easiest way to add a loading spinner in react component when my data is fetching.我正在尝试使用反应钩子使用 state 添加一个加载微调器。我想知道在获取数据时在反应组件中添加加载微调器的最简单方法是什么。 It needs to look fancy.它需要看起来很花哨。 If there is lightweight npm please suggest it's with an example.如果有轻量级的 npm 请举例说明。

I'm not sure if you look for something like that but I suggest to use Progress from MUI我不确定你是否在寻找类似的东西,但我建议使用 MUI 的Progress

As an exemple you can use something like this:作为一个例子,你可以使用这样的东西:

<Paper sx={{width: '100%', p:1}} component="ul">
        <div style={{ height: 400, width: '100%'}}>
          {data.length != 0 ? <DataGrid
            rows={data}
            columns={columns}
            pageSize={5}
            rowsPerPageOptions={[5]}
          /> : <CircularProgress className='progress'/>}           
        </div>
</Paper>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM