@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/dist/CarbonReact.d.ts +6 -5
- package/dist/index.cjs.js +4 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/CarbonReact.tsx +11 -11
package/package.json
CHANGED
package/src/CarbonReact.tsx
CHANGED
|
@@ -48,15 +48,15 @@ export function isJsonString(str: string) {
|
|
|
48
48
|
return true;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
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
|
|
55
|
+
} & P, S> {
|
|
56
|
+
|
|
57
|
+
private static persistentStateMap = new Map<string, { [key: string]: any; }>();
|
|
58
58
|
|
|
59
|
-
context: Context<S
|
|
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<
|
|
132
|
-
nextState: Readonly<
|
|
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<
|
|
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;
|