diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js index d98d1650945ef9..1dd0b14af0a628 100644 --- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js +++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js @@ -197,13 +197,12 @@ export default function useAutocomplete(props) { if (process.env.NODE_ENV !== 'production') { if (typeof optionLabel !== 'string') { + const erroneousReturn = + optionLabel === undefined ? 'undefined' : `${typeof optionLabel} (${optionLabel})`; console.error( [ - 'Material-UI: the `getOptionLabel` method of useAutocomplete do not handle the options correctly.', - `The component expect a string but received ${typeof optionLabel}.`, - `For the input option: ${JSON.stringify( - newValue, - )}, \`getOptionLabel\` returns: ${optionLabel}.`, + `Material-UI: the \`getOptionLabel\` method of ${componentName} returned ${erroneousReturn} instead of a string for`, + JSON.stringify(newValue), ].join('\n'), ); }