The Black Rose
The Black Rose6mo ago

conversation id undefiend error

getting this error when i click on a conversation in chat app and consol log says the conversation id is undefiend any idea how i can fix this ?
No description
19 Replies
erquhart
erquhart6mo ago
Looks like conversation id is undefined
The Black Rose
The Black RoseOP6mo ago
if any one could help me it would be great instead of saying the obvious tnx agian sir
erquhart
erquhart6mo ago
Is this from a template? You'll want to go through some basic troubleshooting steps, starting with logging the missing value directly, and determining where it's supposed to be set and why it isn't happening. Folks can assist better if you share relevant code.
The Black Rose
The Black RoseOP6mo ago
which channel you recommend for that im new to this discord community general ?
erquhart
erquhart6mo ago
Welcome! You're in the right spot for help, just need to share more info for folks to be able to help. With the error message you've shared, all I can see is that conversationId is undefined at runtime.
The Black Rose
The Black RoseOP6mo ago
ok ty again ❤️
type Props = {
params: {
conversationId: Id<"conversations">;
};
};

const ConversationPage = ({ params: { conversationId } }: Props) => {
const conversation = useQuery(api.conversation.get, { id: conversationId });

const [removeFriendDialogOpen, setRemoveFriendDialogOpen] = useState(false);
const [deleteGroupDialogOpen, setDeleteGroupDialogOpen] = useState(false);
const [leaveGroupDialogOpen,
setLeaveGroupDialogOpen] = useState(false);
const [callType, setCallType] = useState<"audio" | "video" | null>(null);

return conversation === undefined ? (
type Props = {
params: {
conversationId: Id<"conversations">;
};
};

const ConversationPage = ({ params: { conversationId } }: Props) => {
const conversation = useQuery(api.conversation.get, { id: conversationId });

const [removeFriendDialogOpen, setRemoveFriendDialogOpen] = useState(false);
const [deleteGroupDialogOpen, setDeleteGroupDialogOpen] = useState(false);
const [leaveGroupDialogOpen,
setLeaveGroupDialogOpen] = useState(false);
const [callType, setCallType] = useState<"audio" | "video" | null>(null);

return conversation === undefined ? (
this is page.tsx for the conversations
erquhart
erquhart6mo ago
Do you have any type errors? Typescript should be complaining wherever this component is used if it's possible for conversationId to be undefined.
The Black Rose
The Black RoseOP6mo ago
typescirpt
import { v } from "convex/values";
import { defineSchema, defineTable } from "convex/server";

export default defineSchema({
users: defineTable({
username: v.string(),
imageUrl: v.string(),
clerkId: v.string(),
email: v.string(),
})
.index("by_email", ["email"])
.index("by_clerkId", ["clerkId"]),
requests: defineTable({
sender: v.id("users"),
receiver: v.id("users"),
})
.index("by_receiver", ["receiver"])
.index("by_receiver_sender", ["receiver", "sender"]),
friends: defineTable({
user1: v.id("users"),
user2: v.id("users"),
conversationId: v.id("conversations"),
})
.index("by_user1", ["user1"])
.index("by_user2", ["user2"])
.index("by_conversationId", ["conversationId"]),
conversations: defineTable({
name: v.optional(v.string()),
isGroup: v.boolean(),
lastMessageId: v.optional(v.id("messages")),
}),
conversationMembers: defineTable({
memberId: v.id("users"),
conversationId: v.id("conversations"),
lastSeenMessage: v.optional(v.id("messages")),
})
.index("by_memberId", ["memberId"])
.index("by_conversationId", ["conversationId"])
.index("by_memberId_conversationId", ["memberId", "conversationId"]),
messages: defineTable({
senderId: v.id("users"),
conversationId: v.id("conversations"),
type: v.string(),
content: v.array(v.string()),
}).index("by_conversationId", ["conversationId"]),
});
typescirpt
import { v } from "convex/values";
import { defineSchema, defineTable } from "convex/server";

export default defineSchema({
users: defineTable({
username: v.string(),
imageUrl: v.string(),
clerkId: v.string(),
email: v.string(),
})
.index("by_email", ["email"])
.index("by_clerkId", ["clerkId"]),
requests: defineTable({
sender: v.id("users"),
receiver: v.id("users"),
})
.index("by_receiver", ["receiver"])
.index("by_receiver_sender", ["receiver", "sender"]),
friends: defineTable({
user1: v.id("users"),
user2: v.id("users"),
conversationId: v.id("conversations"),
})
.index("by_user1", ["user1"])
.index("by_user2", ["user2"])
.index("by_conversationId", ["conversationId"]),
conversations: defineTable({
name: v.optional(v.string()),
isGroup: v.boolean(),
lastMessageId: v.optional(v.id("messages")),
}),
conversationMembers: defineTable({
memberId: v.id("users"),
conversationId: v.id("conversations"),
lastSeenMessage: v.optional(v.id("messages")),
})
.index("by_memberId", ["memberId"])
.index("by_conversationId", ["conversationId"])
.index("by_memberId_conversationId", ["memberId", "conversationId"]),
messages: defineTable({
senderId: v.id("users"),
conversationId: v.id("conversations"),
type: v.string(),
content: v.array(v.string()),
}).index("by_conversationId", ["conversationId"]),
});
no idont get any thing the ui works but when i click on a conversation i get errors like this
erquhart
erquhart6mo ago
Type errors won't stop the ui from working
The Black Rose
The Black RoseOP6mo ago
sending ss a momment
erquhart
erquhart6mo ago
If typescript is not complaining, I would look for type assertions that might be hiding the problem. Try npx tsc to check for type errors
The Black Rose
The Black RoseOP6mo ago
ok ty again iwill add more code for context mean while
The Black Rose
The Black RoseOP6mo ago
this is the npx tsc log it seems there alot of problem 😅
erquhart
erquhart6mo ago
You'll want to exclude the public directory in your tsconfig, once you do that there are only 12 errors remaining Then go through those remaining errors. There are some in what you shared that include "Type 'undefined' is not assignable to type 'string'." - that's probably what you're looking for.
The Black Rose
The Black RoseOP6mo ago
ty for the answering ❤️ well i fixed all the error i got from npx tsc and yet getting same error for some reason it points to api which i cant understand why
The Black Rose
The Black RoseOP6mo ago
this the app deployed on vercel https://ouan-app.vercel.app/conversations
Chat App
Realtime chat app built using NextJS
The Black Rose
The Black RoseOP6mo ago
No description
The Black Rose
The Black RoseOP6mo ago
producing this error and the first picture qwhen i run npm run dev
Michal Srb
Michal Srb6mo ago
Your file path route param conversationid has lowercase i but your React code has uppercase I in conversationId.

Did you find this page helpful?