@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/dist/CarbonReact.d.ts +0 -2
- package/dist/index.cjs.js +2 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +2 -12
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/CarbonReact.tsx +3 -15
package/dist/index.esm.js
CHANGED
|
@@ -4371,15 +4371,14 @@ function isJsonString(str) {
|
|
|
4371
4371
|
}
|
|
4372
4372
|
class CarbonReact extends Component {
|
|
4373
4373
|
static allInstances = new Map();
|
|
4374
|
-
static activeInstances = new Map();
|
|
4375
4374
|
context = createContext(this.state);
|
|
4376
4375
|
target;
|
|
4377
4376
|
static _instance;
|
|
4378
4377
|
static getInstance(instanceId) {
|
|
4379
4378
|
const identifier = this.generateIdentifier(instanceId);
|
|
4380
4379
|
if (undefined !== instanceId) {
|
|
4381
|
-
if (CarbonReact.
|
|
4382
|
-
return CarbonReact.
|
|
4380
|
+
if (CarbonReact.allInstances.has(identifier)) {
|
|
4381
|
+
return CarbonReact.allInstances.get(identifier);
|
|
4383
4382
|
}
|
|
4384
4383
|
throw new Error(`No instance has been instantiated yet for class (${this.name}) with instanceId (${instanceId})`);
|
|
4385
4384
|
}
|
|
@@ -4407,11 +4406,6 @@ class CarbonReact extends Component {
|
|
|
4407
4406
|
constructor(props) {
|
|
4408
4407
|
super(props);
|
|
4409
4408
|
const identifier = this.generateIdentifier();
|
|
4410
|
-
if (CarbonReact.activeInstances.has(identifier)) {
|
|
4411
|
-
throw new Error(`${identifier} instance already exists in the DOM! Each instance should have a unique instanceId.`);
|
|
4412
|
-
}
|
|
4413
|
-
// Register the new instance
|
|
4414
|
-
CarbonReact.activeInstances.set(identifier, this);
|
|
4415
4409
|
if (props.persistentState && CarbonReact.allInstances.has(identifier)) {
|
|
4416
4410
|
// Reuse the state from the existing instance
|
|
4417
4411
|
this.state = CarbonReact.allInstances.get(identifier).state;
|
|
@@ -4434,10 +4428,6 @@ class CarbonReact extends Component {
|
|
|
4434
4428
|
const className = this.constructor.name;
|
|
4435
4429
|
return this.props.instanceId ? `${className}-${this.props.instanceId}` : className;
|
|
4436
4430
|
}
|
|
4437
|
-
componentWillUnmount() {
|
|
4438
|
-
const identifier = this.generateIdentifier();
|
|
4439
|
-
CarbonReact.activeInstances.delete(identifier);
|
|
4440
|
-
}
|
|
4441
4431
|
shouldComponentUpdate(nextProps, nextState, _nextContext) {
|
|
4442
4432
|
changed(this.constructor.name + ' (C6Api)', 'props', this.props, nextProps);
|
|
4443
4433
|
changed(this.constructor.name + ' (C6Api)', 'state', this.state, nextState);
|