@etsoo/react 1.3.50 → 1.3.51

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.
@@ -27,14 +27,17 @@ export function CommonPage(props) {
27
27
  Object.assign(sx, {
28
28
  padding: paddings
29
29
  });
30
- const isMounted = React.useRef();
30
+ const [state] = React.useState({});
31
31
  // Fab padding
32
32
  const fabPadding = MUGlobal.increase(MUGlobal.pagePaddings, fabPaddingAdjust);
33
33
  // Labels
34
34
  const labels = Labels.CommonPage;
35
35
  // Update
36
36
  const update = onUpdateAll
37
- ? onUpdateAll
37
+ ? async (authorized) => {
38
+ await onUpdateAll(authorized);
39
+ state.loaded = true;
40
+ }
38
41
  : onUpdate
39
42
  ? (authorized) => {
40
43
  if (authorized == null || authorized)
@@ -46,16 +49,17 @@ export function CommonPage(props) {
46
49
  onRefresh();
47
50
  }
48
51
  : undefined;
49
- // onUpdateAll support to load after page mounted
50
- if (onUpdateAll != null && isMounted.current) {
51
- onUpdateAll();
52
- }
53
52
  React.useEffect(() => {
54
- isMounted.current = true;
55
53
  return () => {
56
- isMounted.current = false;
54
+ state.loaded = false;
57
55
  };
58
56
  }, []);
57
+ React.useEffect(() => {
58
+ // onUpdateAll support to load after page mounted
59
+ if (onUpdateAll != null && state.loaded) {
60
+ onUpdateAll();
61
+ }
62
+ });
59
63
  // Return the UI
60
64
  return (React.createElement(React.Fragment, null,
61
65
  update && React.createElement(ReactAppStateDetector, { update: update }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.3.50",
3
+ "version": "1.3.51",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,7 +50,7 @@ export function CommonPage(props: CommonPageProps) {
50
50
  padding: paddings
51
51
  });
52
52
 
53
- const isMounted = React.useRef<boolean>();
53
+ const [state] = React.useState<{ loaded?: boolean }>({});
54
54
 
55
55
  // Fab padding
56
56
  const fabPadding = MUGlobal.increase(
@@ -63,7 +63,10 @@ export function CommonPage(props: CommonPageProps) {
63
63
 
64
64
  // Update
65
65
  const update = onUpdateAll
66
- ? onUpdateAll
66
+ ? async (authorized?: boolean) => {
67
+ await onUpdateAll(authorized);
68
+ state.loaded = true;
69
+ }
67
70
  : onUpdate
68
71
  ? (authorized?: boolean) => {
69
72
  if (authorized == null || authorized) onUpdate();
@@ -74,19 +77,19 @@ export function CommonPage(props: CommonPageProps) {
74
77
  }
75
78
  : undefined;
76
79
 
77
- // onUpdateAll support to load after page mounted
78
- if (onUpdateAll != null && isMounted.current) {
79
- onUpdateAll();
80
- }
81
-
82
80
  React.useEffect(() => {
83
- isMounted.current = true;
84
-
85
81
  return () => {
86
- isMounted.current = false;
82
+ state.loaded = false;
87
83
  };
88
84
  }, []);
89
85
 
86
+ React.useEffect(() => {
87
+ // onUpdateAll support to load after page mounted
88
+ if (onUpdateAll != null && state.loaded) {
89
+ onUpdateAll();
90
+ }
91
+ });
92
+
90
93
  // Return the UI
91
94
  return (
92
95
  <React.Fragment>