@etsoo/react 1.3.51 → 1.3.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,8 +35,9 @@ export function CommonPage(props) {
35
35
  // Update
36
36
  const update = onUpdateAll
37
37
  ? async (authorized) => {
38
+ state.loading = true;
38
39
  await onUpdateAll(authorized);
39
- state.loaded = true;
40
+ state.firstLoaded = true;
40
41
  }
41
42
  : onUpdate
42
43
  ? (authorized) => {
@@ -51,12 +52,17 @@ export function CommonPage(props) {
51
52
  : undefined;
52
53
  React.useEffect(() => {
53
54
  return () => {
54
- state.loaded = false;
55
+ state.loading = false;
56
+ state.firstLoaded = false;
55
57
  };
56
58
  }, []);
57
59
  React.useEffect(() => {
58
- // onUpdateAll support to load after page mounted
59
- if (onUpdateAll != null && state.loaded) {
60
+ if (state.loading) {
61
+ state.loading = false;
62
+ return;
63
+ }
64
+ // onUpdateAll support to load after page loaded
65
+ if (onUpdateAll != null && state.firstLoaded) {
60
66
  onUpdateAll();
61
67
  }
62
68
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.3.51",
3
+ "version": "1.3.52",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,7 +50,10 @@ export function CommonPage(props: CommonPageProps) {
50
50
  padding: paddings
51
51
  });
52
52
 
53
- const [state] = React.useState<{ loaded?: boolean }>({});
53
+ const [state] = React.useState<{
54
+ firstLoaded?: boolean;
55
+ loading?: boolean;
56
+ }>({});
54
57
 
55
58
  // Fab padding
56
59
  const fabPadding = MUGlobal.increase(
@@ -64,8 +67,9 @@ export function CommonPage(props: CommonPageProps) {
64
67
  // Update
65
68
  const update = onUpdateAll
66
69
  ? async (authorized?: boolean) => {
70
+ state.loading = true;
67
71
  await onUpdateAll(authorized);
68
- state.loaded = true;
72
+ state.firstLoaded = true;
69
73
  }
70
74
  : onUpdate
71
75
  ? (authorized?: boolean) => {
@@ -79,13 +83,19 @@ export function CommonPage(props: CommonPageProps) {
79
83
 
80
84
  React.useEffect(() => {
81
85
  return () => {
82
- state.loaded = false;
86
+ state.loading = false;
87
+ state.firstLoaded = false;
83
88
  };
84
89
  }, []);
85
90
 
86
91
  React.useEffect(() => {
87
- // onUpdateAll support to load after page mounted
88
- if (onUpdateAll != null && state.loaded) {
92
+ if (state.loading) {
93
+ state.loading = false;
94
+ return;
95
+ }
96
+
97
+ // onUpdateAll support to load after page loaded
98
+ if (onUpdateAll != null && state.firstLoaded) {
89
99
  onUpdateAll();
90
100
  }
91
101
  });