I am running into the following Error while following this tutorial https://www.youtube.com/watch?v=QiTq5WrWoJw&t=8176s
I am having issues connecting my individual messages into my firebase application. My error in the console focuses on the following code.
I am trying to send a message within in an indvidiual "room" within firebase so a collection of rooms with unique messages within each room.
function ChatInput(channelName, channelId) {
const [input, setInput] = useState('');
const sendMessage = (e) => {
e.preventDefault(); //prevents refresh of the page
if(!channelId) {
return false;
}
db.collection("rooms").doc(channelId).collection("messages").add({
message: input,
timestamp: firebase.firestore.FieldValue.serverTimestamp(),
user: 'Daniel Peters',
userImage:'https://wallpapercave.com/wp/j8Sd6Uv.jpg',
});
setInput('');
};
return (
<ChatInputContainer>
<form>
<input value={input} onChange={(e) => setInput(e.target.value)} placeholder= {`Message #${channelName}`} />
<Button hidden type='submit' onClick={sendMessage}>
SEND
</Button>
</form>
</ChatInputContainer>
)
}
export default ChatInput;
I have tried different version of redux and firebase to see if that was the issue, however the issue is obviously not resolved. Any guidance would be great!