File tree Expand file tree Collapse file tree 4 files changed +12
-6
lines changed
bundle/hooks/useScrollIntoView Expand file tree Collapse file tree 4 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @siberiacancode/reactuse" ,
3- "version" : " 0.2.30 " ,
3+ "version" : " 0.2.31 " ,
44 "description" : " The ultimate collection of react hooks" ,
55 "author" : {
66 "name" : " SIBERIA CAN CODE 🧊" ,
Original file line number Diff line number Diff line change 1- import { useEffect , useRef } from 'react' ;
1+ import { useRef } from 'react' ;
22import { getElement , isTarget } from '@/utils/helpers' ;
3+ import { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect' ;
34import { useRefState } from '../useRefState/useRefState' ;
45/**
56 * @name useScrollIntoView
@@ -40,7 +41,7 @@ export const useScrollIntoView = (...params) => {
4041 immediately = true
4142 } = options ?? { } ;
4243 const elementRef = useRef ( null ) ;
43- useEffect ( ( ) => {
44+ useIsomorphicLayoutEffect ( ( ) => {
4445 if ( ! immediately ) return ;
4546 if ( ! target && ! internalRef . state ) return ;
4647 const element = ( target ? getElement ( target ) : internalRef . current ) ?? window ;
Original file line number Diff line number Diff line change 1- import { useEffect , useRef } from 'react' ;
1+ import { useRef } from 'react' ;
22
33import type { HookTarget } from '@/utils/helpers' ;
44
55import { getElement , isTarget } from '@/utils/helpers' ;
66
77import type { StateRef } from '../useRefState/useRefState' ;
88
9+ import { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect' ;
910import { useRefState } from '../useRefState/useRefState' ;
1011
1112/** The scroll into view options type */
@@ -74,7 +75,7 @@ export const useScrollIntoView = ((...params: any[]) => {
7475 } = options ?? { } ;
7576 const elementRef = useRef < Element > ( null ) ;
7677
77- useEffect ( ( ) => {
78+ useIsomorphicLayoutEffect ( ( ) => {
7879 if ( ! immediately ) return ;
7980 if ( ! target && ! internalRef . state ) return ;
8081
Original file line number Diff line number Diff line change 11import { useScrollTo } from '@siberiacancode/reactuse' ;
22
33const Demo = ( ) => {
4- const scrollTo = useScrollTo < HTMLDivElement > ( { x : 0 , y : 260 } ) ;
4+ const scrollTo = useScrollTo < HTMLDivElement > ( {
5+ x : 0 ,
6+ y : 260 ,
7+ behavior : 'smooth'
8+ } ) ;
59
610 return (
711 < div >
You can’t perform that action at this time.
0 commit comments