Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

DCC items reset to default value on interval

I have a dash app built that relies on some dcc.Input and dcc.RadioItems. I also have interval components for updating a table. Every time the interval component fires, it resets the other dcc components back to their original values I set in the layout. How can I stop the resetting on interval?

You could probably add a RadioItem that toggles the dcc.Interval's interval attribute on and off (or at least, short and long)

Here’s a simple example :slight_smile:

import dash_core_components as dcc
import dash_html_components as html
import dash
import datetime

app = dash.Dash()

app.layout = html.Div([
            {'label': 'Every second', 'value': 1000},
            {'label': 'Every 5 seconds', 'value': 5000},
            {'label': 'Off', 'value': 60*60*1000} # or just every hour

    dash.dependencies.Output('display-time', 'children'),
    events=[dash.dependencies.Event('my-interval', 'interval')])
def display_time():
    return str(

    dash.dependencies.Output('my-interval', 'interval'),
    [dash.dependencies.Input('set-time', 'value')])
def update_interval(value):
    return value

if __name__ == '__main__':
1 Like