From 241d9a2c87171629b5a571550cc6ea16c16bf6db Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Wed, 23 Oct 2024 22:45:02 +0100 Subject: [PATCH] switch to useSWRImmutable --- packages/app-project/src/hooks/useAssignedLevel.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/app-project/src/hooks/useAssignedLevel.js b/packages/app-project/src/hooks/useAssignedLevel.js index 197de58785..71a9affaed 100644 --- a/packages/app-project/src/hooks/useAssignedLevel.js +++ b/packages/app-project/src/hooks/useAssignedLevel.js @@ -4,15 +4,7 @@ https://github.com/zooniverse/front-end-monorepo/issues/6198 */ import { panoptes } from '@zooniverse/panoptes-js' -import useSWR from 'swr' - -const SWRoptions = { - revalidateIfStale: false, - revalidateOnMount: false, - revalidateOnFocus: false, - revalidateOnReconnect: false, - refreshInterval: 0 -} +import useSWRImmutable from 'swr/immutable' async function fetchAssignedWorkflow({ fields = 'configuration', @@ -38,7 +30,7 @@ function useAssignedLevel(assignedWorkflowID, workflows = []) { const key = !existingWorkflow && assignedWorkflowID ? { assignedWorkflowID } : null // skip data fetching when we already have the workflow level - const { data: fetchedWorkflowLevel } = useSWR(key, fetchAssignedWorkflow, SWRoptions) + const { data: fetchedWorkflowLevel } = useSWRImmutable(key, fetchAssignedWorkflow) return fetchedWorkflowLevel || defaultWorkflowLevel }