Techiio-author
Started by Shaleena AgarwalSep 7, 2021

Open
How do I use Ternary operation to change the value of a field in <td>

0 VIEWES 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWES SHARE

I am trying to get the status to change to shared if it's userA and if isshared is true. However, with the code I have below, it's returning shared for every field, even when isShared is false.

import React from "react";
import { useSelector } from "react-redux";
import { getLocalStorageStore } from "@/store/localStorage/utils";

const FileResults: React.FC<FileResultType> = props => {
const { results, filename, status = "shared" } = props;

const { email = "", isShared = false } = useSelector(getLocalStorageStore);
const isUserA = email.toLowerCase().includes("usera");

return (
<>
<tr className="file-result">
<td>{results || "--"}</td>
<td>{filename || "--"}</td>
<td>{isUserA && isShared === true ? status : "private"}</td>
</tr>
</>
);
};

export default FileResults;

Note: this is what I have in my FileResultType

export interface FileResultType {
results: string;
filename: string;
status: string;
}

0 Replies

You must be Logged in to reply
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance