Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Error - Expected the output type to be a list or tuple but got None

$
0
0

@user123 wrote:

I have a callback that is triggered by pressing any of the two buttons - ‘orders_button’/‘dashboard_button’.

@app.callback(
                [Output(component_id='url', component_property='pathname'),
                 Output(component_id='page_header', component_property='children')],
                [Input(component_id='orders_button', component_property='n_clicks'),
                Input(component_id='dashboard_button', component_property='n_clicks')]
            )
def process_home(n_clicks_orders, n_clicks_dashboard): 
    ctx = dash.callback_context
        
    if (ctx.triggered and ctx.triggered[0]['value'] != 0):
        trigger_input_id = ctx.triggered[0]['prop_id'].split('.')[0]
    
        if trigger_input_id == 'orders_button':
            return ('/orders', page_header_1)
        elif trigger_input_id == 'dashboard_button':
            return ('/dashboard',page_header_2)

When I run the app, I see a warning message (the program still runs):

dash.exceptions.InvalidCallbackReturnValue: The callback …url.pathname…page_header.children… is a multi-output. Expected the output type to be a list or tuple but got None.

What puzzles me is that this message appears in my console even before the callback is triggered i.e. even before I have pressed any of the above two buttons. I have confirmed that the callback is not triggered when this message appears by debugging.

Am I doing something silly or is it a bug ?

Interestingly, if I add the following two lines to the end of the callback, the warning disappears:
else:
return (no_update, no_update)

Adding the above two lines seems to replace the None with no_update.

I don’t understand this. What is going on ?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles