Hello The Dash community !
I working on multi pages app using dcc.Store component.
My understanding with dcc.Store is that component is declared once in app.py, then since dcc.Store gets loaded it get available in any page when needed,
I’m having trouble with following code.
app.py code.
app.layout = dbc.Container([
html.Div([
dcc.Store(id='store-1', data={}, storage_type='local'),
dcc.Store(id='store-2', data={}, storage_type='local'),
dcc.Store(id='store-3', data={}, storage_type='local'),
dcc.Store(id='store-4', data={}, storage_type='local'),
dcc.Store(id='store-5', data={}, storage_type='local'),
dcc.Store(id='store-6', data={}, storage_type='local'),
dcc.Store(id='store-7', data={}, storage_type='local'),
dcc.Store(id='store-8', data={}, storage_type='local'),
dcc.Store(id='store-9', data={}, storage_type='local'),
dcc.Store(id='store-10', data={}, storage_type='local'),
dcc.Store(id='store-11', data={}, storage_type='local'),
dcc.Store(id='store-12', data={}, storage_type='local'),
dcc.Store(id='store-13', data={}, storage_type='local'),
dcc.Store(id='store-14', data={}, storage_type='local'),
dcc.Store(id='store-15', data={}, storage_type='local'),
dcc.Store(id='store-16', data={}, storage_type='local'),
dcc.Store(id='store-list_dict', data={}, storage_type='local'),
dcc.Store(id='store-words-list', data={}, storage_type='local'),
dcc.Store(id='store-years-list', data={}, storage_type='local')
]),
dbc.Row([
dbc.Col([
sidebar],
xs=4,
sm=4,
md=2,
lg=2,
xxl=2),
dbc.Col([
dash.page_container],
xs=8,
sm=8,
md=10,
lg=10,
xxl=10),
])
],
fluid=True
)
if __name__ == '__main__':
app.run(debug=True)
With following code I checked dcc.Store component “store-words-list-output” get loaded)
layout = dbc.Container([
html.Div(
[dcc.Store(id=f'store-{i}', data=new_list[i].to_dict('records')) for i in range(len(new_list))
]
),
html.Div([dcc.Store(id='store-list_dict', data=l_of_lists)]),
html.Div([dcc.Store(id='store-words-list', data=list_of_d_words)]),
html.Div([dcc.Store(id='store-years-list', data=list_of_d_years)]),
**html.Div(id='store-words-list-output', children=[]),**
Other code lines....
@callback(
Output('store-words-list-output', 'children'),
Input('store-words-list', 'data')
)
def return_val(data):
print(f'data: {data[0]['Stroke']}')
return data[0]['Stroke']
This works fine, return list of dictionaries
Code from page_2, where the problem occurs:
dash.register_page(__name__,
path='/lri',
title='db-lri',
name='db-lri',
location="sidebar")
**layout = html.Div(id='store-words-output')**
**@callback(**
** Output('store-words-output', 'children'),**
** Input('store-words-list', 'data')**
** )**
**def check(data):**
** print(f'children: {data}')**
** return data**
This code do not return anything ==> children: {}
I do not see where I am wrong…
I need help on this, I maybe wrong with principle
Thank you for your time on this !!