Skip to content

Commit

Permalink
fix(performance): add back useMemo on DocumentPaneContext value (#…
Browse files Browse the repository at this point in the history
…5458)

Co-authored-by: Rico Kahler <[email protected]>
  • Loading branch information
stipsan and ricokahler authored Jan 19, 2024
1 parent 9795480 commit bd141cd
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export interface DocumentPaneContextValue {
setTimelineMode: (mode: TimelineMode) => void
setTimelineRange(since: string | null, rev: string | null): void
setIsDeleting: (state: boolean) => void
source?: string
timelineError: Error | null
timelineMode: TimelineMode
timelineStore: TimelineStore
Expand Down
171 changes: 114 additions & 57 deletions packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -557,63 +557,120 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => {
[formStateRef],
)

const documentPane: DocumentPaneContextValue = {
actions,
activeViewId,
badges,
changesOpen,
closeInspector,
collapsedFieldSets,
collapsedPaths,
compareValue,
connectionState,
displayed,
documentId,
documentIdRaw,
documentType,
editState,
fieldActions,
focusPath,
inspector: currentInspector || null,
inspectors,
onBlur: handleBlur,
onChange: handleChange,
onFocus: handleFocus,
onPathOpen: setOpenPath,
onHistoryClose: handleHistoryClose,
onHistoryOpen: handleHistoryOpen,
onInspectClose: handleLegacyInspectClose,
onMenuAction: handleMenuAction,
onPaneClose: handlePaneClose,
onPaneSplit: handlePaneSplit,
onSetActiveFieldGroup: handleSetActiveFieldGroup,
onSetCollapsedPath: handleOnSetCollapsedPath,
onSetCollapsedFieldSet: handleOnSetCollapsedFieldSet,
openInspector,
index,
inspectOpen,
validation,
menuItemGroups: menuItemGroups || [],
paneKey,
previewUrl,
ready,
schemaType: schemaType!,
isPermissionsLoading,
permissions,
setTimelineMode,
setTimelineRange,
setIsDeleting,
isDeleting,
isDeleted,
timelineError,
timelineMode,
timelineStore,
title,
value,
views,
formState,
unstable_languageFilter: languageFilter,
}
const documentPane: DocumentPaneContextValue = useMemo(
() => ({
actions,
activeViewId,
badges,
changesOpen,
closeInspector,
collapsedFieldSets,
collapsedPaths,
compareValue,
connectionState,
displayed,
documentId,
documentIdRaw,
documentType,
editState,
fieldActions,
focusPath,
inspector: currentInspector || null,
inspectors,
onBlur: handleBlur,
onChange: handleChange,
onFocus: handleFocus,
onPathOpen: setOpenPath,
onHistoryClose: handleHistoryClose,
onHistoryOpen: handleHistoryOpen,
onInspectClose: handleLegacyInspectClose,
onMenuAction: handleMenuAction,
onPaneClose: handlePaneClose,
onPaneSplit: handlePaneSplit,
onSetActiveFieldGroup: handleSetActiveFieldGroup,
onSetCollapsedPath: handleOnSetCollapsedPath,
onSetCollapsedFieldSet: handleOnSetCollapsedFieldSet,
openInspector,
index,
inspectOpen,
validation,
menuItemGroups: menuItemGroups || [],
paneKey,
previewUrl,
ready,
schemaType: schemaType!,
isPermissionsLoading,
permissions,
setTimelineMode,
setTimelineRange,
setIsDeleting,
isDeleting,
isDeleted,
timelineError,
timelineMode,
timelineStore,
title,
value,
views,
formState,
unstable_languageFilter: languageFilter,
}),
[
actions,
activeViewId,
badges,
changesOpen,
closeInspector,
collapsedFieldSets,
collapsedPaths,
compareValue,
connectionState,
currentInspector,
displayed,
documentId,
documentIdRaw,
documentType,
editState,
fieldActions,
focusPath,
formState,
handleBlur,
handleChange,
handleFocus,
handleHistoryClose,
handleHistoryOpen,
handleLegacyInspectClose,
handleMenuAction,
handleOnSetCollapsedFieldSet,
handleOnSetCollapsedPath,
handlePaneClose,
handlePaneSplit,
handleSetActiveFieldGroup,
index,
inspectOpen,
inspectors,
isDeleted,
isDeleting,
isPermissionsLoading,
languageFilter,
menuItemGroups,
openInspector,
paneKey,
permissions,
previewUrl,
ready,
schemaType,
setOpenPath,
setTimelineRange,
timelineError,
timelineMode,
timelineStore,
title,
validation,
value,
views,
],
)

useEffect(() => {
if (connectionState === 'reconnecting') {
Expand Down

2 comments on commit bd141cd

@vercel
Copy link

@vercel vercel bot commented on bd141cd Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

performance-studio – ./

performance-studio-git-next.sanity.build
performance-studio.sanity.build

@vercel
Copy link

@vercel vercel bot commented on bd141cd Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

test-studio – ./

test-studio-git-next.sanity.build
test-studio.sanity.build

Please sign in to comment.