Black Lives Matter. Please consider donating to Black Girls Code today.

Avoiding redundant rendering with complicated interaction dependencies

I have a dash app which uses a number of components to select an image. When I use one of those components, the (same) image renders multiple times, presumably because of the complicated dependencies.


Are there best practices or design philosophies which would help eliminate this kind of problem? I’d rather not have to “gate” the output by adding an “update” button.

Thanks for reporting! This looks like it would be a bug. I’ve updated some of this logic in recent versions of dash-renderer (see changelog: I believe that the bug fixes from 0.9.0 should have fixed this issue. Could you check what version you are on?

import dash_renderer

I tried to replicate this (on v0.11.0) with the following example but was unable to: updating the “grandparent” component indeed updated “parent-a” and “parent-b” but the “child” was only updated once “parent-a” and “parent-b” were finished.

import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()
app.layout = html.Div([
        options=[{'label': i, 'value': i} for i in range(5)],

@app.callback(Output('parent-a', 'children'), [Input('grandparent', 'value')])
def update_parent_a(value):
    return 'Parent A with {}'.format(value)

@app.callback(Output('parent-b', 'children'), [Input('grandparent', 'value')])
def update_parent_b(value):
    return 'Parent B with {}'.format(value)

@app.callback(Output('child', 'children'),
              [Input('parent-a', 'children'),
               Input('parent-b', 'children')])
def update_child(parent_a, parent_b):
    return 'Child with "{}" and "{}"'.format(parent_a, parent_b)

if __name__ == '__main__':

You were right, I had been forgetting to upgrade dash_renderer with everything else and was on version 0.7.4. I’ve updated to 0.12.0rc1 and it updates correctly now. Thanks!

1 Like

:sweat_smile: Great, glad that fixed things for you!

ICYMI - is always updated with the latest versions and you can always check out the file in each of the repos for a list of changes.

Thanks again for reporting!