@carbonorm/carbonreact 4.0.10 → 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.
@@ -17,11 +17,12 @@ export interface iCarbonReactState {
17
17
  export declare const initialRequiredCarbonORMState: iCarbonReactState;
18
18
  export declare const initialCarbonReactState: iCarbonReactState & iRestfulObjectArrayTypes;
19
19
  export declare function isJsonString(str: string): boolean;
20
- declare abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactState> extends Component<{
20
+ export interface iCarbonReactProps<P = {}, S extends iCarbonReactState = iCarbonReactState> {
21
21
  children?: ReactNode | ReactNode[];
22
22
  instanceId?: string;
23
23
  websocket?: Omit<iCarbonWebSocketProps<P, S>, "instance"> | false;
24
- } & P, S> {
24
+ }
25
+ declare abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbonReactState> extends Component<iCarbonReactProps<P, S> & P, S> {
25
26
  private static persistentStateMap;
26
27
  context: Context<S & iCarbonReactState>;
27
28
  protected target: typeof CarbonReact;
@@ -37,11 +38,7 @@ declare abstract class CarbonReact<P = {}, S extends iCarbonReactState = iCarbon
37
38
  } = {}>(rest: Omit<iDeleteRestfulObjectArrays<ObjectType, S, P>, "instance">) => void;
38
39
  static lastLocation: string;
39
40
  static whyDidYouRender: boolean;
40
- protected constructor(props: {
41
- children?: ReactNode | ReactNode[];
42
- shouldStatePersist?: boolean | undefined;
43
- websocket?: boolean | iCarbonWebSocketProps<P, S> | undefined;
44
- } & P);
41
+ protected constructor(props: any);
45
42
  shouldComponentUpdate(nextProps: Readonly<P>, nextState: Readonly<S>, _nextContext: any): boolean;
46
43
  componentDidUpdate(_prevProps: Readonly<P>, _prevState: Readonly<S>, _snapshot?: any): void;
47
44
  render(): ReactElement;
package/dist/index.cjs.js CHANGED
@@ -4390,6 +4390,12 @@ class CarbonReact extends react.Component {
4390
4390
  static whyDidYouRender = true;
4391
4391
  constructor(props) {
4392
4392
  super(props);
4393
+ if (!props.instanceId && new.target._instance) {
4394
+ // todo - instanceId being unique should solve this, but.... how
4395
+ // This is a singleton pattern, we can only have one instance of this class
4396
+ throw new Error(`${new.target.name} instance already exists! CarbonReact extended classes can only be referenced once in DOM`);
4397
+ }
4398
+ new.target.instance = (this);
4393
4399
  this.target = new.target;
4394
4400
  console.log('CarbonORM TSX CONSTRUCTOR');
4395
4401
  // this is the magic that allows each class that's extends this to have a static instance - a singleton pattern