chained callback does not used latest value of Store data
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Describe your context
dash 1.16.3
dash-core-components 1.3.1
dash-html-components 1.0.1
dash-renderer 1.1.2
dash-table 4.4.1
Describe the bug
Chained callback does not use value of data changed in first callback for Store element.
first callback(Output(store, data)Output(text,children)Input(button, n_clicks))
chained_callback(Input(text,children),State(store,data))
See mini example associated
Expected behavior
When first callback is triggered it should first change the data value of store and use that value in the state of chained callback.
Screenshots
When page is loaded:

When I click on button1

Below is a minimalist example of the code:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
from dash.exceptions import PreventUpdate
app = dash.Dash()
app.layout = html.Div(
[
dcc.Store(id="store", storage_type="session", data={'store_content': "ini"}),
html.Button("b1", id="button1"),
html.Button("b2", id="button2"),
html.Div(children="button callback not executed", id="button_output"),
html.Div(children="chianed callback not executed", id="chained_output"),
]
)
@app.callback(
Output("button_output", "children"),
Output("store", "data"),
Input("button1", "n_clicks"),
Input("button2", "n_clicks"),
State("store", "data")
)
def button_callback(n1, n2, data):
ctx = dash.callback_context
if not ctx.triggered:
raise PreventUpdate
button_id = ctx.triggered[0]['prop_id'].split('.')[0]
if button_id == "button1":
data['store_content'] = "button1"
return "button 1 pressed: " + repr(data), data
elif button_id == "button2":
data['store_content'] = "button2"
return "button 2 pressed: " + repr(data), data
@app.callback(
Output("chained_output", "children"),
Input("button_output", "children"),
State("store", "data")
)
def chained_callback(text, data):
return "chained callback: " + repr(data)
if __name__ == '__main__':
app.run_server(debug=True)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the minimal Dash example to reproduce the callback chain and observe the Store value received by chained_callback. Trace how callback outputs and Store state are propagated between callbacks; done means the chained callback receives the updated Store data after the first callback runs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- full-stack
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100