State and context are on the public instance

This commit is contained in:
Dan committed 2019-06-12 16:50:15 +01:00
1 parent f352fe2625
commit 3137553f6d
1 file changed
+16 -6
+16 -6
View File
@@ -560,8 +560,12 @@ export function attach(
}
}
}
context = internalInstance.context || null;
state = internalInstance.state || null;
const publicInstance = internalInstance._instance;
if (publicInstance != null) {
context = publicInstance.context || null;
state = publicInstance.state || null;
}
}
return {
@@ -696,16 +700,22 @@ export function attach(
function setInState(id: number, path: Array<string | number>, value: any) {
const internalInstance = idToInternalInstanceMap.get(id);
if (internalInstance != null) {
setIn(internalInstance.state, path, value);
internalInstance.forceUpdate();
const publicInstance = internalInstance._instance;
if (publicInstance != null) {
setIn(publicInstance.state, path, value);
forceUpdate(publicInstance);
}
}
}
function setInContext(id: number, path: Array<string | number>, value: any) {
const internalInstance = idToInternalInstanceMap.get(id);
if (internalInstance != null) {
setIn(internalInstance.context, path, value);
forceUpdate(internalInstance);
const publicInstance = internalInstance._instance;
if (publicInstance != null) {
setIn(publicInstance.context, path, value);
forceUpdate(publicInstance);
}
}
}