Skip to content

Commit

Permalink
fix: resolving react compiler issue with ignored dep
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanl17 committed Oct 25, 2024
1 parent be592fe commit 0b345fa
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/sanity/src/core/store/_legacy/datastores.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable camelcase */

import {useTelemetry} from '@sanity/telemetry/react'
import {useCallback, useMemo} from 'react'
import {useCallback, useMemo, useRef} from 'react'
import {of} from 'rxjs'
import {useRouter} from 'sanity/router'

Expand Down Expand Up @@ -300,6 +300,7 @@ export function useReleasesStore(): ReleaseStore {
const currentUser = useCurrentUser()
const studioClient = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS)
const router = useRouter()
const perspectiveRef = useRef(router.perspectiveState.perspective)

// TODO: Include hidden layers state.
return useMemo(() => {
Expand All @@ -311,7 +312,7 @@ export function useReleasesStore(): ReleaseStore {
createReleaseStore({
client: studioClient,
currentUser,
perspective: router.perspectiveState.perspective,
perspective: perspectiveRef.current,
})

resourceCache.set({
Expand All @@ -321,7 +322,5 @@ export function useReleasesStore(): ReleaseStore {
})

return releaseStore
/* eslint-disable-next-line react-hooks/exhaustive-deps
-- router.persistenceState only used for initial perspective, not for updates */
}, [resourceCache, workspace, studioClient, currentUser])
}

0 comments on commit 0b345fa

Please sign in to comment.