Skip to content

Commit 906884b

Browse files
committed
comments on the graphLayout hack
1 parent 8b3abd2 commit 906884b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

dash-renderer/src/components/error/CallbackGraph/CallbackGraphContainer.react.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ function CallbackGraph() {
195195
cy.nodes().each(n => {
196196
positions[n.id()] = n.position();
197197
});
198+
199+
// Hack! We're mutating the redux store directly here, rather than
200+
// dispatching an action, because we don't want this to trigger a
201+
// rerender, we just want the layout to persist when the callback graph
202+
// is rerendered - either because there's new profile information to
203+
// display or because the graph was closed and reopened. The latter is
204+
// the reason we're not using component state to store the layout.
198205
profile.graphLayout = {
199206
name: 'preset',
200207
fit: false,

dash-renderer/src/reducers/profile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const profile = (state = defaultState, action) => {
3838
updated: [id],
3939
resources: state.resources,
4040
callbacks: state.callbacks,
41+
// graphLayout is never passed in via actions, because we don't
42+
// want it to trigger a rerender of the callback graph.
43+
// See CallbackGraphContainer.react
4144
graphLayout: state.graphLayout
4245
};
4346

0 commit comments

Comments
 (0)