Hi i am getting this error while doing the multiple output to change option and value in dropdown component.
the code:
app.layout = html.Div([
dcc.Input(id=‘device-input’,value=’’),
html.Button(‘Add Device’,id=‘add-device’),
dcc.Dropdown(
id='device-dropdown',
options=[],
value=[],
multi=True,
)
])
@app.callback(
[Output(‘device-dropdown’, ‘options’), Output(‘device-dropdown’, ‘value’)],
[Input(‘add-device’,‘n_clicks’)],
[State(‘device-input’, ‘value’), State(‘device-dropdown’, ‘options’),State(‘device-dropdown’, ‘value’)])
def callback(n_clicks, input_value, current_options, device_list):
if not input_value:
return current_options
if input_value not in device_list:
device_list.append(input_value)
current_options.append({'label': input_value, 'value': input_value})
return (current_options, device_list)
The error:
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 2328, in call
return self.wsgi_app(environ, start_response)
File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 2314, in wsgi_app
response = self.handle_exception(e)
File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 1760, in handle_exception
reraise(exc_type, exc_value, tb)
File “/usr/local/lib/python3.7/site-packages/flask/_compat.py”, line 36, in reraise
raise value
File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 2311, in wsgi_app
response = self.full_dispatch_request()
File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 1834, in full_dispatch_request
rv = self.handle_user_exception(e)
File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 1737, in handle_user_exception
reraise(exc_type, exc_value, tb)
File “/usr/local/lib/python3.7/site-packages/flask/_compat.py”, line 36, in reraise
raise value
File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 1832, in full_dispatch_request
rv = self.dispatch_request()
File “/usr/local/lib/python3.7/site-packages/flask/app.py”, line 1818, in dispatch_request
return self.view_functionsrule.endpoint
File “/usr/local/lib/python3.7/site-packages/dash/dash.py”, line 1152, in dispatch
response.set_data(self.callback_map[output]‘callback’)
File “/usr/local/lib/python3.7/site-packages/dash/dash.py”, line 1055, in add_context
len(output_value)
dash.exceptions.InvalidCallbackReturnValue: Invalid number of output values for …device-dropdown.options…device-dropdown.value…
Expected 2 got 0