I have a table data where there are section called Item, Time and ValidTill so for example one of the Item has a time of April 2nd 2022, 3:08:01 pm and is ValidTill time of April 2nd 2022, 3:09:26 pm so after this validtill expires i have make an api call in useEffect which i am already doing it once the component mounts but i also want it to run when validTill expires so how can it be achieved
const [quotesData, setQuotesData] = useState([]);
useEffect(() => {
getRandomdata();
}, []);
async function getRandomdata() {
const result = await RandomApi.get(`/quotes/${symbolId}`);
setQuotesData(result.data.payload);
}
<Table stickyHeader className={classes.stickyHeader}>
<TableHead>
<TableRow>
<TableCell>Item</TableCell>
<TableCell>Time</TableCell>
<TableCell>Validtill</TableCell>
</TableRow>
</TableHead>
<TableBody>
{quotesData.map(({Item, time, valid_till }) => (
<TableRow key={Item}>
<TableCell>{Item}</TableCell>
<TableCell>
{moment(time).format("MMMM Do YYYY, h:mm:ss a")}
</TableCell>
<TableCell>
{moment(valid_till).format("MMMM Do YYYY, h:mm:ss a")}
</TableCell>
</TableRow>
))}
</TableBody>
</Table>