@carbonorm/carbonreact 4.0.1 → 4.0.2

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.1",
4
+ "version": "4.0.2",
5
5
  "browser": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "main": "dist/index.cjs.js",
@@ -48,15 +48,15 @@ export function isJsonString(str: string) {
48
48
  return true;
49
49
  }
50
50
 
51
- const persistentStateMap = new Map<string, iCarbonReactState>();
52
-
53
- abstract class CarbonReact<P = {}, S extends { [key: string]: any; } = {}> extends Component<{
51
+ abstract class CarbonReact<P = {}, S extends { [key: string]: any; } = typeof initialCarbonReactState> extends Component<{
54
52
  children?: ReactNode | ReactNode[],
55
53
  instanceId?: string,
56
54
  websocket?: Omit<iCarbonWebSocketProps, "instance"> | boolean
57
- } & P, S & iCarbonReactState> {
55
+ } & P, S> {
56
+
57
+ private static persistentStateMap = new Map<string, { [key: string]: any; }>();
58
58
 
59
- context: Context<S & iCarbonReactState> = createContext(this.state);
59
+ context: Context<S> = createContext(this.state);
60
60
 
61
61
  // Private static member
62
62
  // we actually implement this in the constructor todo - test this
@@ -101,9 +101,9 @@ abstract class CarbonReact<P = {}, S extends { [key: string]: any; } = {}> exten
101
101
  instance: this
102
102
  })
103
103
 
104
- if (this.props.instanceId && persistentStateMap.has(this.props.instanceId)) {
104
+ if (this.props.instanceId && CarbonReact.persistentStateMap.has(this.props.instanceId)) {
105
105
 
106
- this.state = persistentStateMap.get(this.props.instanceId) as S & iCarbonReactState;
106
+ this.state = CarbonReact.persistentStateMap.get(this.props.instanceId) as S & iCarbonReactState;
107
107
 
108
108
  } else {
109
109
 
@@ -128,12 +128,12 @@ abstract class CarbonReact<P = {}, S extends { [key: string]: any; } = {}> exten
128
128
 
129
129
 
130
130
  shouldComponentUpdate(
131
- nextProps: Readonly<any>,
132
- nextState: Readonly<iCarbonReactState>,
131
+ nextProps: Readonly<P>,
132
+ nextState: Readonly<S>,
133
133
  _nextContext: any): boolean {
134
134
 
135
135
  if (this.props.instanceId) {
136
- persistentStateMap.set(this.props.instanceId, nextState);
136
+ CarbonReact.persistentStateMap.set(this.props.instanceId, nextState);
137
137
  }
138
138
 
139
139
  changed(this.constructor.name + ' (C6Api)', 'props', this.props, nextProps);
@@ -144,7 +144,7 @@ abstract class CarbonReact<P = {}, S extends { [key: string]: any; } = {}> exten
144
144
 
145
145
  }
146
146
 
147
- componentDidUpdate(_prevProps: Readonly<any>, _prevState: Readonly<iCarbonReactState>, _snapshot?: any) {
147
+ componentDidUpdate(_prevProps: Readonly<P>, _prevState: Readonly<S>, _snapshot?: any) {
148
148
  if (CarbonReact.lastLocation !== location.pathname) {
149
149
  CarbonReact.lastLocation = location.pathname;
150
150
  const websocket = this.state.websocket;