1313import { AriaLabelingProps , DOMAttributes , FocusableElement } from '@react-types/shared' ;
1414import { MutableRefObject , useCallback , useEffect , useState } from 'react' ;
1515import { useLayoutEffect } from '@react-aria/utils' ;
16- import { useSyncExternalStore } from 'use-sync-external-store/shim' ;
16+ import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js ' ;
1717
1818export type AriaLandmarkRole = 'main' | 'region' | 'search' | 'navigation' | 'form' | 'banner' | 'contentinfo' | 'complementary' ;
1919
@@ -85,7 +85,11 @@ function subscribe(fn: () => void) {
8585 return ( ) => document . removeEventListener ( 'react-aria-landmark-manager-change' , fn ) ;
8686}
8787
88- function getLandmarkManager ( ) : LandmarkManagerApi {
88+ function getLandmarkManager ( ) : LandmarkManagerApi | null {
89+ if ( typeof document === 'undefined' ) {
90+ return null ;
91+ }
92+
8993 // Reuse an existing instance if it has the same or greater version.
9094 let instance = document [ landmarkSymbol ] ;
9195 if ( instance && instance . version >= LANDMARK_API_VERSION ) {
@@ -100,8 +104,8 @@ function getLandmarkManager(): LandmarkManagerApi {
100104}
101105
102106// Subscribes a React component to the current landmark manager instance.
103- function useLandmarkManager ( ) : LandmarkManagerApi {
104- return useSyncExternalStore ( subscribe , getLandmarkManager ) ;
107+ function useLandmarkManager ( ) : LandmarkManagerApi | null {
108+ return useSyncExternalStore ( subscribe , getLandmarkManager , getLandmarkManager ) ;
105109}
106110
107111class LandmarkManager implements LandmarkManagerApi {
0 commit comments