I am working on a whatsapp clone app using react, firebase

messages, user name, timestamp are recieved from firestore using this code:
<div className="chat__body">
{messages.map(message => (
<p className={`chat__message ${true && "chat__reciever"}`}>
<span className="chat__name">{message.name}</span>
{message.message}
<span className="chat__timestamp">
{new Date(message.timestamp?.toDate())
.toUTCString()}
</span>
</p>
))}
</div>
<div className="chat__footer">
<InsertEmoticonIcon />
<form >
<input value={input} onChange={(event) =>
setInput(event.target.value)} placeholder="Type a message" type="text" />
<button onClick={sendMessage} type="submit">Send </button>
</form>
<MicIcon />
</div>
The input field texts are captured in {sendMessage} which are viewed in console as input value.
//probably sendMessage onClick event is causing this error.
const sendMessage = (event) => {
event.preventDefault();
console.log("You typed ", input);
db.collection('groups').doc(groupId)
.collection(messages).add({
message: input,
name: user.displayName,
timestamp: firebase.firestore.FieldValue.serverTimestamp(),
});
setInput('');
}
as the firestore is set, the inputs are set as messages, name and timestamps set from google authentication in collection like this:
When I type on the input field, those inputs are supposed to be showed in chat instead showing error:TypeError: u.split is not a function


uis just prior to using it to understand the issue. The error means thatuis not a string or an array, where.split()can be used. - Scott Marcusu? - Scott Marcus