mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 04:43:35 +00:00
refactor: memoise paramseditor
This commit is contained in:
committed by
Carlos Valente
parent
5c86914cda
commit
36062458fe
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import QRCode from 'react-qr-code';
|
||||
import { useViewportSize } from '@mantine/hooks';
|
||||
import { CustomFields, OntimeEvent, ProjectData, Runtime, Settings } from 'ontime-types';
|
||||
@@ -105,7 +105,10 @@ export default function Backstage(props: BackstageProps) {
|
||||
|
||||
// gather option data
|
||||
const defaultFormat = getDefaultFormat(settings?.timeFormat);
|
||||
const backstageOptions = getBackstageOptions(defaultFormat, customFields);
|
||||
const backstageOptions = useMemo(
|
||||
() => getBackstageOptions(defaultFormat, customFields),
|
||||
[defaultFormat, customFields],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={`backstage ${isMirrored ? 'mirror' : ''}`} data-testid='backstage-view'>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { IoAdd } from 'react-icons/io5';
|
||||
import {
|
||||
CustomFields,
|
||||
@@ -63,7 +63,10 @@ export default function Countdown({
|
||||
|
||||
// gather option data
|
||||
const defaultFormat = getDefaultFormat(settings?.timeFormat);
|
||||
const countdownOptions = getCountdownOptions(defaultFormat, customFields, subscriptions);
|
||||
const countdownOptions = useMemo(
|
||||
() => getCountdownOptions(defaultFormat, customFields, subscriptions),
|
||||
[defaultFormat, customFields, subscriptions],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={`countdown ${isMirrored ? 'mirror' : ''}`} data-testid='countdown-view'>
|
||||
|
||||
@@ -45,7 +45,7 @@ export default function TimelinePage(props: TimelinePageProps) {
|
||||
|
||||
// populate options
|
||||
const defaultFormat = getDefaultFormat(settings?.timeFormat);
|
||||
const progressOptions = getTimelineOptions(defaultFormat);
|
||||
const progressOptions = useMemo(() => getTimelineOptions(defaultFormat), [defaultFormat]);
|
||||
|
||||
const titleNow = now?.title ?? '-';
|
||||
const dueText = getLocalizedString('timeline.due').toUpperCase();
|
||||
|
||||
Reference in New Issue
Block a user