1nwf / Produx-v2

Logical operator can be refactored to optional chain JS-W1044
Anti-pattern
Minor
8 months ago8 months old
Prefer using an optional chain expression instead, as it's more concise and easier to read
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} />
Prefer using an optional chain expression instead, as it's more concise and easier to read
 50    )
 51
 52    useEffect(() => {
 53        if (commentsReqInfo.data && commentsReqInfo.data.comments) { 54            setComments([...comments, ...commentsReqInfo.data.comments])
 55            // setLastId(commentsReqInfo.data.lastId);
 56        }
Prefer using an optional chain expression instead, as it's more concise and easier to read
 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        />
Prefer using an optional chain expression instead, as it's more concise and easier to read
 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);
Prefer using an optional chain expression instead, as it's more concise and easier to read
 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"}