1 | import React, { useState, useEffect } from "react";
|
2 | import loading2 from "../assets/images/loading2.gif";
|
3 | import { Empty } from "antd";
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | export default function NullLoading({ data, children, empty }) {
|
13 | const [v, set] = useState(data);
|
14 |
|
15 | useEffect(() => {
|
16 | if (data) {
|
17 | setTimeout(() => {
|
18 | set(data);
|
19 | }, 200);
|
20 | }
|
21 | }, [data]);
|
22 |
|
23 | if (v !== null) {
|
24 | if (empty && Array.isArray(v) && v.length === 0) {
|
25 | return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
|
26 | }
|
27 | return children;
|
28 | }
|
29 |
|
30 | return (
|
31 | <div
|
32 | style={{
|
33 | height: "150px",
|
34 | width: "100%",
|
35 | background: "white",
|
36 | display: "flex",
|
37 | alignItems: "center",
|
38 | justifyContent: "center",
|
39 | }}
|
40 | >
|
41 | <img src={loading2} width="16" />
|
42 | </div>
|
43 | );
|
44 | }
|