Skip to content

Commit cb1f299

Browse files
committed
update to remove hashes of decendents upon newRender
1 parent 5932df4 commit cb1f299

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

dash/dash-renderer/src/actions/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const actionList = {
1010
ON_ERROR: 1,
1111
SET_HOOKS: 1,
1212
INSERT_COMPONENT: 1,
13-
REMOVE_COMPONENT: 1
13+
REMOVE_COMPONENT: 1,
14+
RESET_COMPONENT_STATE: 1
1415
};
1516

1617
export const getAction = action => {

dash/dash-renderer/src/actions/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const insertComponent = createAction(getAction('INSERT_COMPONENT'));
2222
export const removeComponent = createAction(getAction('REMOVE_COMPONENT'));
2323

2424
export const onPropChange = createAction(getAction('ON_PROP_CHANGE'));
25+
export const resetComponentState = createAction(getAction('RESET_COMPONENT_STATE'));
2526

2627
export function updateProps(payload) {
2728
return (dispatch, getState) => {

dash/dash-renderer/src/reducers/reducer.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ const layoutHashes = (state = {}, action) => {
4949
},
5050
state
5151
);
52+
} else if (action.type === 'RESET_COMPONENT_STATE') {
53+
const { itempath } = action.payload;
54+
if (itempath) {
55+
const prefixStr = stringifyPath(itempath);
56+
// Remove all hashes for keys starting with prefixStr
57+
return Object.fromEntries(
58+
Object.entries(state).filter(
59+
([key]) => !key.startsWith(prefixStr)
60+
)
61+
);
62+
};
5263
}
5364
return state;
5465
};

dash/dash-renderer/src/wrapper/DashWrapper.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {useSelector, useDispatch, batch} from 'react-redux';
2121
import ComponentErrorBoundary from '../components/error/ComponentErrorBoundary.react';
2222
import {DashLayoutPath, UpdatePropsPayload} from '../types/component';
2323
import {DashConfig} from '../config';
24-
import {notifyObservers, onError, updateProps} from '../actions';
24+
import {notifyObservers, onError, updateProps, resetComponentState} from '../actions';
2525
import {getWatchedKeys, stringifyId} from '../actions/dependencies';
2626
import {
2727
createElement,
@@ -90,6 +90,10 @@ function DashWrapper({
9090
if (renderH in memoizedKeys.current) {
9191
delete memoizedKeys.current[renderH];
9292
}
93+
// Reset hashes and layout for this component and all descendants
94+
dispatch(resetComponentState({
95+
itempath: componentPath,
96+
}));
9397
} else {
9498
newRender.current = false;
9599
}

0 commit comments

Comments
 (0)