@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.
@@ -24,7 +24,6 @@ declare abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbon
24
24
  websocket?: Omit<iCarbonWebSocketProps<P, S>, "instance"> | false;
25
25
  } & P, S> {
26
26
  private static allInstances;
27
- private static activeInstances;
28
27
  context: Context<S & iCarbonReactState>;
29
28
  protected target: typeof CarbonReact;
30
29
  protected static _instance: ThisType<CarbonReact<any, any>>;
@@ -47,7 +46,6 @@ declare abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbon
47
46
  } & P);
48
47
  private static generateIdentifier;
49
48
  private generateIdentifier;
50
- componentWillUnmount(): void;
51
49
  shouldComponentUpdate(nextProps: Readonly<P>, nextState: Readonly<S>, _nextContext: any): boolean;
52
50
  componentDidUpdate(_prevProps: Readonly<P>, _prevState: Readonly<S>, _snapshot?: any): void;
53
51
  render(): ReactElement;
package/dist/index.cjs.js CHANGED
@@ -4373,15 +4373,14 @@ function isJsonString(str) {
4373
4373
  }
4374
4374
  class CarbonReact extends react.Component {
4375
4375
  static allInstances = new Map();
4376
- static activeInstances = new Map();
4377
4376
  context = react.createContext(this.state);
4378
4377
  target;
4379
4378
  static _instance;
4380
4379
  static getInstance(instanceId) {
4381
4380
  const identifier = this.generateIdentifier(instanceId);
4382
4381
  if (undefined !== instanceId) {
4383
- if (CarbonReact.activeInstances.has(identifier)) {
4384
- return CarbonReact.activeInstances.get(identifier);
4382
+ if (CarbonReact.allInstances.has(identifier)) {
4383
+ return CarbonReact.allInstances.get(identifier);
4385
4384
  }
4386
4385
  throw new Error(`No instance has been instantiated yet for class (${this.name}) with instanceId (${instanceId})`);
4387
4386
  }
@@ -4409,11 +4408,6 @@ class CarbonReact extends react.Component {
4409
4408
  constructor(props) {
4410
4409
  super(props);
4411
4410
  const identifier = this.generateIdentifier();
4412
- if (CarbonReact.activeInstances.has(identifier)) {
4413
- throw new Error(`${identifier} instance already exists in the DOM! Each instance should have a unique instanceId.`);
4414
- }
4415
- // Register the new instance
4416
- CarbonReact.activeInstances.set(identifier, this);
4417
4411
  if (props.persistentState && CarbonReact.allInstances.has(identifier)) {
4418
4412
  // Reuse the state from the existing instance
4419
4413
  this.state = CarbonReact.allInstances.get(identifier).state;
@@ -4436,10 +4430,6 @@ class CarbonReact extends react.Component {
4436
4430
  const className = this.constructor.name;
4437
4431
  return this.props.instanceId ? `${className}-${this.props.instanceId}` : className;
4438
4432
  }
4439
- componentWillUnmount() {
4440
- const identifier = this.generateIdentifier();
4441
- CarbonReact.activeInstances.delete(identifier);
4442
- }
4443
4433
  shouldComponentUpdate(nextProps, nextState, _nextContext) {
4444
4434
  changed(this.constructor.name + ' (C6Api)', 'props', this.props, nextProps);
4445
4435
  changed(this.constructor.name + ' (C6Api)', 'state', this.state, nextState);