Skip to content

Commit

Permalink
switch to useSWRImmutable
Browse files Browse the repository at this point in the history
  • Loading branch information
eatyourgreens committed Oct 25, 2024
1 parent 92db666 commit 241d9a2
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions packages/app-project/src/hooks/useAssignedLevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
}
Expand Down

0 comments on commit 241d9a2

Please sign in to comment.