Repository: plotly/dash
File: dash/dash-renderer/src/actions/callbacks.ts (TypeScript)

Code before:
        };

        if (config.ui) {
            dispatch(
                updateResourceUsage({
                    id: payload.output,
                    usage: resources,
                    status,
                    result,
                    inputs,
                    state
                })
            );
        }
    }

    return result;
}

function updateComponent(component_id: any, props: any) {
    return function (dispatch: any, getState: any) {
        const paths = getState().paths;
        const componentPath = getPath(paths, component_id);
        if (typeof componentPath === 'undefined') {
            // Can't find the component that was defined in the running keyword,
            // Let's skip the component to prevent the dashboard from crashing.
            return;
        }
        dispatch(
            updateProps({
                props,
                itempath: componentPath
            })
        );
        dispatch(notifyObservers({id: component_id, props}));
    };
}

/**
 * Update a component props with `running`/`progress`/`set_props` calls.
 *
 * @param outputs Props to update.
 * @param cb The originating callback info.
 * @returns
 */
function sideUpdate(outputs: SideUpdateOutput, cb: ICallbackPayload) {
    return function (dispatch: any, getState: any) {
        toPairs(outputs)
            .reduce((acc, [id, value], i) => {
                let componentId = id,
                    propName,

Review comment (refactor):
I think it would be better to throw an error unless `config.suppress_callback_exceptions=True`. It is in state.config, could refactor line 335 to `const {paths,config} = getState();`

Code after:
        };

        if (config.ui) {
            dispatch(
                updateResourceUsage({
                    id: payload.output,
                    usage: resources,
                    status,
                    result,
                    inputs,
                    state
                })
            );
        }
    }

    return result;
}

function updateComponent(component_id: any, props: any, cb: ICallbackPayload) {
    return function (dispatch: any, getState: any) {
        const {paths, config} = getState();
        const componentPath = getPath(paths, component_id);
        if (!componentPath) {
            if (!config.suppress_callback_exceptions) {
                dispatchError(dispatch)(
                    'ID running component not found in layout',
                    [
                        'Component defined in running keyword not found in layout.',
                        `Component id: "${stringifyId(component_id)}"`,
                        'This ID was used in the callback(s) for Output(s):',
                        `${cb.output}`,
                        'You can suppress this exception by setting',
                        '`suppress_callback_exceptions=True`.'
                    ]
                );
            }
            // We need to stop further processing because functions further on
            // can't operate on an 'undefined' object, and they will throw an
            // error.
            return;
        }
        dispatch(
            updateProps({
                props,
                itempath: componentPath
            })
        );
        dispatch(notifyObservers({id: component_id, props}));
    };
}