@openmrs/esm-react-utils 5.0.3-pre.857 → 5.0.3-pre.863

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-react-utils",
3
- "version": "5.0.3-pre.857",
3
+ "version": "5.0.3-pre.863",
4
4
  "license": "MPL-2.0",
5
5
  "description": "React utilities for OpenMRS.",
6
6
  "browser": "dist/openmrs-esm-react-utils.js",
@@ -56,11 +56,11 @@
56
56
  "react-i18next": "11.x"
57
57
  },
58
58
  "devDependencies": {
59
- "@openmrs/esm-api": "^5.0.3-pre.857",
60
- "@openmrs/esm-config": "^5.0.3-pre.857",
61
- "@openmrs/esm-error-handling": "^5.0.3-pre.857",
62
- "@openmrs/esm-extensions": "^5.0.3-pre.857",
63
- "@openmrs/esm-globals": "^5.0.3-pre.857",
59
+ "@openmrs/esm-api": "^5.0.3-pre.863",
60
+ "@openmrs/esm-config": "^5.0.3-pre.863",
61
+ "@openmrs/esm-error-handling": "^5.0.3-pre.863",
62
+ "@openmrs/esm-extensions": "^5.0.3-pre.863",
63
+ "@openmrs/esm-globals": "^5.0.3-pre.863",
64
64
  "dayjs": "^1.10.8",
65
65
  "i18next": "^19.6.0",
66
66
  "react": "^18.1.0",
@@ -69,5 +69,5 @@
69
69
  "rxjs": "^6.5.3",
70
70
  "webpack": "^5.88.0"
71
71
  },
72
- "gitHead": "f215f8246d3a4d875bfa7f8cdd636c2f7e3db2a5"
72
+ "gitHead": "3413bcd8508080e92d3f13e8f5280d05dfb5190e"
73
73
  }
package/src/Extension.tsx CHANGED
@@ -90,10 +90,13 @@ export const Extension: React.FC<ExtensionProps> = ({
90
90
  return () => {
91
91
  if (parcel && parcel.current) {
92
92
  const status = parcel.current.getStatus();
93
- console.log(`Unmounting ${parcel.current}; status: ${status}`);
94
93
  switch (status) {
95
94
  case "MOUNTING":
96
- parcel.current.mountPromise.then(parcel.current.unmount);
95
+ parcel.current.mountPromise.then(() => {
96
+ if (parcel.current?.getStatus() === "MOUNTED") {
97
+ parcel.current.unmount();
98
+ }
99
+ });
97
100
  break;
98
101
  case "MOUNTED":
99
102
  parcel.current.unmount();
@@ -101,10 +104,7 @@ export const Extension: React.FC<ExtensionProps> = ({
101
104
  case "UPDATING":
102
105
  if (updatePromise.current) {
103
106
  updatePromise.current.then(() => {
104
- if (
105
- parcel.current &&
106
- parcel.current.getStatus() === "MOUNTED"
107
- ) {
107
+ if (parcel.current?.getStatus() === "MOUNTED") {
108
108
  parcel.current.unmount();
109
109
  }
110
110
  });
@@ -125,21 +125,22 @@ export const Extension: React.FC<ExtensionProps> = ({
125
125
  ]);
126
126
 
127
127
  useEffect(() => {
128
- if (parcel.current && parcel.current.update) {
128
+ if (
129
+ parcel.current &&
130
+ parcel.current.update &&
131
+ parcel.current.getStatus() !== "UNMOUNTING"
132
+ ) {
129
133
  Promise.all([parcel.current.mountPromise, updatePromise.current]).then(
130
134
  () => {
131
- if (parcel?.current?.update) {
135
+ if (
136
+ parcel?.current?.getStatus() === "MOUNTED" &&
137
+ parcel.current.update
138
+ ) {
132
139
  updatePromise.current = parcel.current.update({ ...state });
133
140
  }
134
141
  }
135
142
  );
136
143
  }
137
-
138
- return () => {
139
- Promise.resolve(updatePromise.current).then(() => {
140
- updatePromise.current = undefined;
141
- });
142
- };
143
144
  }, [state]);
144
145
 
145
146
  // The extension is rendered into the `<div>`. The `<div>` has relative