Hi there,
i saw an example here
app.layout = html.Div([
html.P('Enter a composite number to see its prime factors'),
dcc.Input(id='num', type='number', debounce=True, min=2, step=1),
html.P(id='err', style={'color': 'red'}),
html.P(id='out')
])
@app.callback(
Output('out', 'children'),
Output('err', 'children'),
Input('num', 'value')
)
def show_factors(num):
if num is None:
# PreventUpdate prevents ALL outputs updating
raise dash.exceptions.PreventUpdate
factors = prime_factors(num)
if len(factors) == 1:
# dash.no_update prevents any single output updating
# (note: it's OK to use for a single-output callback too)
return dash.no_update, '{} is prime!'.format(num)
return '{} is {}'.format(num, ' * '.join(str(n) for n in factors)), ''
When i interact with the input, i can see that i get for 20 the whole sentence from the last return. In this case the output with the id = ‘err’ gets ignored. Why is that so? Shouldn’t i see the sentence displayed two times?
Shouldn’t that output update as well?
And how does dash.no_update work? How did it know to ignore the id=‘err’ ?