Skip to content

Commit 677abb3

Browse files
committed
allows for the componentPath to be updated when moving around in the children and triggering setProps
1 parent 8297e54 commit 677abb3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ function DashWrapper({
6565
const dispatch = useDispatch();
6666
const memoizedKeys: MutableRefObject<MemoizedKeysType> = useRef({});
6767
const newRender = useRef(false);
68+
const renderedPath: any = useRef(null);
6869
let renderComponent: any = null;
6970
let renderComponentProps: any = null;
7071
let renderH: any = null;
@@ -90,9 +91,10 @@ function DashWrapper({
9091
} else {
9192
newRender.current = false;
9293
}
94+
renderedPath.current = componentPath
9395
}, [_newRender]);
9496

95-
const setProps = (newProps: UpdatePropsPayload) => {
97+
const setProps = useCallback((newProps: UpdatePropsPayload) => {
9698
const {id} = renderComponentProps;
9799
const {_dash_error, ...restProps} = newProps;
98100

@@ -101,7 +103,7 @@ function DashWrapper({
101103
dispatch((dispatch, getState) => {
102104
const currentState = getState();
103105
const {graphs} = currentState;
104-
const oldLayout = getComponentLayout(componentPath, currentState);
106+
const oldLayout = getComponentLayout(renderedPath.current, currentState);
105107
if (!oldLayout) return;
106108
const {props: oldProps} = oldLayout;
107109
if (!oldProps) return;
@@ -144,13 +146,13 @@ function DashWrapper({
144146
dispatch(
145147
updateProps({
146148
props: changedProps,
147-
itempath: componentPath,
149+
itempath: renderedPath.current,
148150
renderType: 'internal'
149151
})
150152
);
151153
});
152154
});
153-
};
155+
}, [componentPath]);
154156

155157
const createContainer = useCallback(
156158
(container, containerPath, _childNewRender, key = undefined) => {

0 commit comments

Comments
 (0)