293 </div>
294 </div>
295 <AddComment field={channel as string} postId={data.ID} />
296 {comments &&297 comments.map((m, idx) => {298 return (299 <div key={idx}>300 <CommentCard comment={m} />301 </div>302 )303 })}304 </div>
305 )}
306 <div ref={pageEndRef} />
50 )
51
52 useEffect(() => {
53 if (commentsReqInfo.data && commentsReqInfo.data.comments) { 54 setComments([...comments, ...commentsReqInfo.data.comments])
55 // setLastId(commentsReqInfo.data.lastId);
56 }
47 <title>{name} - produx</title>
48 <link
49 rel="icon"
50 href={data && data.product.images 51 ? data.product.images[0]
52 : "/produx2.png"}
53 />
27 }, [getProduct, name]);
28 const [showPrivate, setShowPrivate] = useState(false);
29 useEffect(() => {
30 if (data && data.product.private) { 31 checkIfFollowed(data.product.ID).then((res) => {
32 if (res.data.followed) {
33 setShowPrivate(false);
86 >
87 Select images
88 </div>
89 {images && 90 images.map((i, idx) => ( 91 <div 92 key={idx} 93 className={"flex justify-center w-full"} 94 > 95 {" "} 96 <img 97 src={URL.createObjectURL(i)} 98 className={"max-w-[89%] max-h-[80vh] object-contain rounded-box"} 99 />100 </div>101 ))}102
103 <input
104 type={"file"}
The optional chaining operator can be used to perform null checks before accessing a property, or calling a function.
Using &&
for this purpose is no longer required.
function getUsernameFromId(id: number): string | undefined {
const user = db.getUser(id)
return user && user.name
}
someFunc && someFunc()
// ^~~~ not necessary
maybeArray && maybeArray[index]
// ^~~~ not necessary
function getUsernameFromId(id: number): string | undefined {
const user = db.getUser(id)
return user?.name
}
someFunc?.()
maybeArray?.[index]