This page outlines changes in Dash version 3.0 and cases where you may need to update an existing app to work with version 3.0. Dash 3.0 is currently available as a release candidate. Install it with
pip install dash==3.0.0rc1
The following were deprecated in previous versions of Dash and have now been removed in Dash 3.0.
Replace long callbacks with background callbacks.
Instead of dash.long_callback.managers.CeleryLongCallbackManager
, use dash.CeleryManager
.
Instead of dash.long_callback.managers.DiskcacheLongCallbackManager
, use dash.DiskcacheManager
.
Instead of the long_callback_manager
argument on the dash.Dash
constructor, use background_callback_manager
.
Also, update @app.long_callback
to be a standard callback with @app.callback
or @dash.callback
, but which sets background=True
.
For example:
python
@app.long_callback(
output=Output("paragraph_id", "children"),
inputs=Input("button_id", "n_clicks"),
manager=long_callback_manager,
)
becomes
python
@callback(
output=Output("paragraph_id", "children"),
inputs=Input("button_id", "n_clicks"),
background=True,
manager=background_callback_manager,
)
The functionality of parameters previously available to customize app.long_callback
are available on app.callback
and dash.callback
: interval
, running
, cancel
, progress
, progress_default
, cache_args_to_ignore
, and manager
.
Here’s a complete app using long callbacks rewritten to use background callbacks:
dcc.LogoutButton
Replace dcc.LogoutButton
with html.Button
or use the Dash Enterprise Auth logout button functionality.
Dash.run_server
To run your app, replace Dash.run_server
with Dash.run
.
The default version of React in Dash 3.0 is React 18.3.1. In most cases, you won’t need to make any updates to your apps and they will continue to work.
If you do need to use the previous default React version (16.14.0) in your app, you can add the following:
import dash
dash._dash_renderer._set_react_version("16.14.0")
app = dash.Dash()
...
dash._dash_renderer._set_react_version("16.14.0")
sets the React version to 16.14.0 and must come before the app instance is created.
The component libraries that are part of Dash, dash.html
and dash.dcc
, now support Python typing
. This provides type hints in IDEs and allows you to add type hints to your code, for example, to callbacks. For example, this callback updates the figure
property of a dcc.Graph
, specifying the return type as a go.Figure
object.
from plotly.graph_objects import Figure
from dash import callback
...
@callback(
Output('my-graph', 'figure'),
Input('my-input', 'value')
)
def update_graph(input_value: str) -> Figure:
df['y'] = df['x'] * int(input_value)
fig = px.line(df, x='x', y='y', title=f'Graph with multiplier {input_value}')
return fig