Question on using dcc.Store in multi-tab structure app. I’d like to persist / store data switching between tabs. My multi-page / tabs dash app structure looks like:
- index.py
- app.py
- Tabs
- tab1.py
- subtab1.py
- subtab2.py
- tab2.py
- tab1.py
- Tabs
index.py renders the layout of from each file depending on the selection.
app.layout = html.Div([
# tabs
html.Div([
dcc.Tabs(
id="tabs",
vertical=True,
className="mb-3",
persistence=True,
children=[
dcc.Tab(label="tab1", value="tab1",
children=[dcc.Tabs(id="subtabs", persistence=True,
children=[dcc.Tab(label='subtab1', value='subtab1'),
dcc.Tab(label='subtab2', value='subtab2')
],
)
]),
dcc.Tab(label="tab2", value="tab2"),
],
)
],
className="row tabs_div"
),
# Tab content
html.Div(id="tab_content"),
])
Now, I’d like to exchange component state / data between different subtabs. subtab1.py contains dcc.Graph and data-table and 'subtab2.py contains a series of dcc.Graph components.
Do I need to add dcc.Store component in both subtab1.py and subtab2.py to store individual components and read from them? I’d like to be able to read components state of subtab1.py in subtab2.py and other files.