Skip to content

Commit

Permalink
memoized rowData
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixKiprotich350 committed Sep 18, 2024
1 parent d813ea1 commit a2e531c
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useCallback } from 'react';
import React, { useState, useEffect, useCallback, useMemo } from 'react';
import { DataTableSkeleton } from '@carbon/react';
import { useTranslation } from 'react-i18next';
import { useActiveTickets } from './useActiveTickets';
Expand All @@ -17,12 +17,16 @@ const QueueScreen: React.FC<QueueScreenProps> = () => {
const selectedLocation = useSelectedQueueLocationUuid();
const locationFilteredTickets = activeTickets;

const rowData = locationFilteredTickets.map((ticket, index) => ({
id: `${index}`,
room: ticket.room,
ticketNumber: ticket.ticketNumber,
status: ticket.status,
}));
const rowData = useMemo(
() =>
activeTickets.map((ticket, index) => ({
id: `${index}`,
room: ticket.room,
ticketNumber: ticket.ticketNumber,
status: ticket.status,
})),
[activeTickets],
);
const readTicket = useCallback(
(queue) => {
if ('speechSynthesis' in window) {
Expand Down

0 comments on commit a2e531c

Please sign in to comment.