Update messages.tsx#5
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/components/messages.tsxThe 'message.sender' object is checked against null before accessing its 'username' property. Since the 'username' property is not optional, this null check is unnecessary and can be removed to improve code readability. - {message.sender?.username ?? "Deleted User"}
+ {message.sender.username}Destructuring assignment can be used to make the code more concise and easier to read. In this case, the 'id' property can be destructured from the 'props' object in the 'MessageInput' component. function MessageInput({ id }: { id: Id<"directMessages" | "channels"> }) {
// ...
}
// can be changed to
function MessageInput({ id }: { id: Id<"directMessages" | "channels"> }) {
const { id } = props;
// ...
}Optional chaining can be used to simplify the null check for nested properties. In this case, the 'imageUpload.previewUrl' property can be accessed using optional chaining. - {imageUpload.previewUrl && (
+ {imageUpload?.previewUrl && ( |
No description provided.