All you need to do is prevent your submit function from calling firebase if your input is empty.
const sendMessage = (e) => {
e.preventDefault();
if (input.length <= 0) return; // This will end the function here if your input is empty
db.collection('channels').doc(channelId).collection('messages').add({
timestamp: firebase.firestore.FieldValue.serverTimestamp(),
message: input,
user: user,
});
setInput('')
}
CLICK HERE to find out more related problems solutions.