I have created a component called QueryForm to be used for search functionality. I am returning in that component this:
You can replace the spaces to empty string while setting the value:
const onChange = (event, { newValue }) => {
setInputValue(newValue.replace(/\s/g, ''));
};