eddiejaoude / video-realtime-chat-react-express

Realtime chat app built with react and express
10 stars 8 forks source link

Sends message even when name and/or chat field is empty. #3

Open SandeepKrSuman opened 3 years ago

SandeepKrSuman commented 3 years ago

eddie_chat_bug

eddiejaoude commented 3 years ago

There is no validation, as I wanted to keep the demo as simple as possible.

This could be achieved with a conditional check, something like this... (untested)

const addMessage = () => {
    if (!author || !message) {
       return;
    }
    const send = { author, message };
    setMessages([...messages, send]);
    socket.emit("chat", send);
    setMessage("");
  };

https://github.com/eddiejaoude/video-realtime-chat-react-express/blob/main/src/App.js#L28

SandeepKrSuman commented 3 years ago

oh! ok got it.

rushikeshadhav commented 3 years ago

May I do this ? Please I am new to open source this will be a very good contribution for me. As this issue is beginner friendly. Could you please assign me @eddiejaoude Thanks

eddiejaoude commented 3 years ago

There is no validation, as I wanted to keep the demo as simple as possible.

Hi @rushikeshadhav , please see the previous comment, I included above for your convenience - but this repo is a simple demo only

rushikeshadhav commented 3 years ago

Ok thanks eddie