@@ -34,7 +34,7 @@ export class ScrollNavigateTopError extends Error {
3434export function useScrollNavigate ( path = "/" , top = 0 , left = 0 ) {
3535
3636 const navigate = useNavigate ( ) ;
37- const [ scrollNavigateError , setScrollNavigateError ] = useState ( ) ;
37+ const [ scrollNavigateError , setScrollNavigateError ] = useState ( null ) ;
3838 const scrollNavigate = useCallback ( ( path , top , left ) => {
3939 if ( typeof path != "string" ) {
4040 setScrollNavigateError ( new ScrollNavigatePathError ( "Path is not a string" ) ) ;
@@ -71,7 +71,7 @@ export function useScrollNavigate(path = "/", top = 0 , left = 0 ) {
7171export const NavigateContext = createContext ( ) ;
7272export const NavigateContextProvider = ( { children} ) => {
7373 const navigate = useNavigate ( ) ;
74- const [ navigationBeacon , setNavigationBeacon ] = useState ( false ) ;
74+ const [ navigationBeacon , setNavigationBeacon ] = useState ( null ) ;
7575 const navigationRef = useRef ( ) ;
7676
7777 const navigateToRef = useCallback ( ( path ) => {
@@ -81,10 +81,10 @@ export const NavigateContextProvider = ({children}) => {
8181 } , [ navigate , setNavigationBeacon ] ) ;
8282
8383 const value = useMemo ( ( ) => { navigationRef , navigateToRef } ,
84- [ navigationRef , navigateToRef ( ) ] ) ;
84+ [ navigationRef , navigateToRef ] ) ;
8585
8686 useLayoutEffect ( ( ) => {
87- if ( navigationBeacon === false ) return
87+ if ( navigationBeacon === false || navigationBeacon === null ) return
8888 if ( navigationRef . current instanceof HTMLElement ) {
8989 const { left, top} = navigationRef . current . getBoundingClientRect ( ) ;
9090 window . scroll ( { left, top, behavior :'smooth' } ) ;
0 commit comments