@carbonorm/carbonreact 4.0.15 → 4.0.16

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbonorm/carbonreact",
3
3
  "license": "MIT",
4
- "version": "4.0.15",
4
+ "version": "4.0.16",
5
5
  "browser": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "main": "dist/index.cjs.js",
@@ -52,7 +52,6 @@ abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactSta
52
52
  } & P, S> {
53
53
 
54
54
  private static allInstances = new Map<string, CarbonReact<any, any>>();
55
- private static activeInstances = new Map<string, CarbonReact<any, any>>();
56
55
 
57
56
  context: Context<S & iCarbonReactState> = createContext(this.state);
58
57
  protected target: typeof CarbonReact;
@@ -64,8 +63,8 @@ abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactSta
64
63
  const identifier = this.generateIdentifier(instanceId);
65
64
 
66
65
  if (undefined !== instanceId) {
67
- if (CarbonReact.activeInstances.has(identifier)) {
68
- return CarbonReact.activeInstances.get(identifier) as T;
66
+ if (CarbonReact.allInstances.has(identifier)) {
67
+ return CarbonReact.allInstances.get(identifier) as T;
69
68
  }
70
69
  throw new Error(`No instance has been instantiated yet for class (${this.name}) with instanceId (${instanceId})`);
71
70
  }
@@ -75,6 +74,7 @@ abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactSta
75
74
  }
76
75
 
77
76
  return this._instance as T;
77
+
78
78
  }
79
79
 
80
80
  static get instance() {
@@ -111,13 +111,6 @@ abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactSta
111
111
 
112
112
  const identifier = this.generateIdentifier();
113
113
 
114
- if (CarbonReact.activeInstances.has(identifier)) {
115
- throw new Error(`${identifier} instance already exists in the DOM! Each instance should have a unique instanceId.`);
116
- }
117
-
118
- // Register the new instance
119
- CarbonReact.activeInstances.set(identifier, this);
120
-
121
114
  if (props.persistentState && CarbonReact.allInstances.has(identifier)) {
122
115
  // Reuse the state from the existing instance
123
116
  this.state = CarbonReact.allInstances.get(identifier)!.state as S & iCarbonReactState;
@@ -144,11 +137,6 @@ abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactSta
144
137
  return this.props.instanceId ? `${className}-${this.props.instanceId}` : className;
145
138
  }
146
139
 
147
- componentWillUnmount() {
148
- const identifier = this.generateIdentifier();
149
- CarbonReact.activeInstances.delete(identifier);
150
- }
151
-
152
140
  shouldComponentUpdate(
153
141
  nextProps: Readonly<P>,
154
142
  nextState: Readonly<S>,