Skip to content

Clientside no_update dispatches empty props updates and unnecessarily renders skipped components #4173

Open

Description

@FistOfMight

Describe your context

Reproduced with Dash 4.1.0, 4.5.0 and 4.5.1, headless Google Chrome 156.0.8078.47 on Linux.

Describe the bug

A clientside callback returning dash_clientside.no_update still produces an empty props update for the skipped component. This replaces its props object, increments its layout hash and can render it unnecessarily. It also happens in single-output callbacks.

The skipped property values remain unchanged. This report concerns the unnecessary update/render work, not value corruption, remounting or dependent callbacks firing.

from dash import Dash, Input, Output, html

app = Dash(__name__)
app.layout = html.Div([
    html.Button("Run", id="run"),
    html.Div(id="active"),
    html.Div("unchanged", id="skipped"),
])
app.clientside_callback(
    """function(n) {
        return [String(n), window.dash_clientside.no_update];
    }""",
    Output("active", "children"),
    Output("skipped", "children"),
    Input("run", "n_clicks"),
    prevent_initial_call=True,
)

if __name__ == "__main__":
    app.run(debug=False)

After the page loads, run this in the browser console:

var before = window.dash_component_api.getLayout('skipped').props;
document.querySelector('#run').click();
setTimeout(() => {
    var after = window.dash_component_api.getLayout('skipped').props;
    console.log({sameProps: before === after, value: after.children});
}, 500);

Actual result: {sameProps: false, value: 'unchanged'}.

For a render check, I used Dash's existing test component DrawCounter, which counts new props received by a component without subscribing to loading state. After five callback invocations, a skipped component received five unnecessary renders. Removing its output from the callback, or using a Python callback returning dash.no_update, produced zero. A skipped dcc.Graph did not call Plotly.react in the same probe.

Expected behavior

The clientside result should omit components with no updated properties, as the server-side path does. Callback/loading lifecycle activity can still occur; there should be no empty response-generated property update for the skipped component.

Cause and proposed fix

In handleClientside, result[idStr] is created before testing retij !== dc.no_update. This leaves a {} entry that executedCallbacks applies, dispatching ON_PROP_CHANGE and incrementing the render hash.

Create the entry only inside that condition. I verified this eliminates the unnecessary renders while preserving normal updates, including a callback updating another prop on the same component. Integration regressions also cover a single sentinel for multiple outputs and pattern-matching outputs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions