Skip to content
Advertisement

Plotly Dash Share Callback Input in another page with dcc.Store

i have a 2-page app, on the first page (app.py), i use dcc.Store to store a value in the session cache, and then trying to load this data in the 2nd page (app2.py), and show it as html.H1.

Here is my code in page one:

dcc.Store(id='session', storage_type='session'), 

then my callback on this page is:

@app.callback(Output('session', 'data'),
              [Input('q1', 'value')])
def q1_value(q1):
     return {'answer1value': q1}

while “q1” is a value from my radioitem.

But when i run this app, nothing is shown up in this H1. I have spent many hours fixing this but fail, would anyone please help ?

Advertisement

Answer

put your

dcc.Store(id='session', storage_type='session'),

onto the app.py, not page1.py, under the

app.layout = html.Div([....])

then your value will be stored here, and can be called from other pages.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement