@carbonorm/carbonreact 4.0.9 → 4.0.11
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 +6 -9
- package/dist/index.cjs.js +8 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +8 -0
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/CarbonReact.tsx +24 -12
- package/src/components/Alert/Alert.tsx +4 -6
package/dist/index.esm.js
CHANGED
|
@@ -4362,6 +4362,7 @@ class CarbonReact extends Component {
|
|
|
4362
4362
|
// Context is for functional components to access the state of this class efficiently
|
|
4363
4363
|
context = createContext(this.state);
|
|
4364
4364
|
target;
|
|
4365
|
+
// @link https://stackoverflow.com/questions/55029032/what-is-typescripts-thistype-used-for
|
|
4365
4366
|
static _instance;
|
|
4366
4367
|
static getInstance() {
|
|
4367
4368
|
return this._instance;
|
|
@@ -4372,6 +4373,7 @@ class CarbonReact extends Component {
|
|
|
4372
4373
|
static set instance(instance) {
|
|
4373
4374
|
this._instance = instance;
|
|
4374
4375
|
}
|
|
4376
|
+
// these are public but the class is abstract
|
|
4375
4377
|
updateRestfulObjectArrays = (rest) => updateRestfulObjectArrays({
|
|
4376
4378
|
instance: this,
|
|
4377
4379
|
...rest
|
|
@@ -4386,6 +4388,12 @@ class CarbonReact extends Component {
|
|
|
4386
4388
|
static whyDidYouRender = true;
|
|
4387
4389
|
constructor(props) {
|
|
4388
4390
|
super(props);
|
|
4391
|
+
if (!props.instanceId && new.target._instance) {
|
|
4392
|
+
// todo - instanceId being unique should solve this, but.... how
|
|
4393
|
+
// This is a singleton pattern, we can only have one instance of this class
|
|
4394
|
+
throw new Error(`${new.target.name} instance already exists! CarbonReact extended classes can only be referenced once in DOM`);
|
|
4395
|
+
}
|
|
4396
|
+
new.target.instance = (this);
|
|
4389
4397
|
this.target = new.target;
|
|
4390
4398
|
console.log('CarbonORM TSX CONSTRUCTOR');
|
|
4391
4399
|
// this is the magic that allows each class that's extends this to have a static instance - a singleton pattern
|