File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
packages/core/src/theme/logic Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change 11import { useLocation } from '@rspress/core/runtime' ;
2- import { useEffect } from 'react' ;
2+ import { useLayoutEffect } from 'react' ;
33
44/**
55 * Parse CSS length value to number (in pixels)
@@ -49,7 +49,7 @@ function scrollToTarget(target: HTMLElement) {
4949export function useScrollAfterNav ( ) {
5050 const location = useLocation ( ) ;
5151
52- useEffect ( ( ) => {
52+ useLayoutEffect ( ( ) => {
5353 const decodedHash = decodeURIComponent ( window . location . hash ) ;
5454 if ( decodedHash . length > 0 ) {
5555 const target = document . getElementById ( decodedHash . slice ( 1 ) ) ;
Original file line number Diff line number Diff line change 1- import { useEffect } from 'react' ;
1+ import { useLayoutEffect } from 'react' ;
22import { useLocation } from 'react-router-dom' ;
33
44/**
@@ -8,7 +8,7 @@ import { useLocation } from 'react-router-dom';
88export function useScrollReset ( ) {
99 const { pathname } = useLocation ( ) ;
1010
11- useEffect ( ( ) => {
11+ useLayoutEffect ( ( ) => {
1212 const decodedHash = decodeURIComponent ( window . location . hash ) ;
1313 if ( decodedHash . length === 0 ) {
1414 window . scrollTo ( 0 , 0 ) ;
You can’t perform that action at this time.
0 commit comments