1- import { useCallback , useLayoutEffect , useRef } from 'react' ;
1+ import { useCallback , useLayoutEffect , useRef , useState } from 'react' ;
22import { Animated , View } from 'react-native' ;
33import { getHiddenTranslateValues } from '../utils/animationDirection' ;
44import type { Direction , Notification } from '../types' ;
@@ -9,6 +9,7 @@ import { FABRIC_ENABLED, MAX_VALUE } from '../constants';
99 * Also, can update hiddenTranslate* values by using updateHiddenValueByDirection function depending on the direction
1010 */
1111export const useLayout = ( { enterFrom } : Notification ) => {
12+ const [ isLayoutReady , setLayoutReady ] = useState ( false ) ;
1213 const ref = useRef < View > ( null ) ;
1314 // store current direction to handle the case when component dimensions changes (trigger onLayout)
1415 // while active direction != enterFrom (e.g. when exitTo is different than enterFrom, and notification started hiding animation).
@@ -65,6 +66,7 @@ export const useLayout = ({ enterFrom }: Notification) => {
6566 componentWidth . setValue ( width ) ;
6667
6768 updateHiddenValueByDirection ( currentDirection . current ) ;
69+ setLayoutReady ( true ) ;
6870 } ,
6971 [ componentHeight , componentWidth , updateHiddenValueByDirection ]
7072 ) ;
@@ -112,5 +114,6 @@ export const useLayout = ({ enterFrom }: Notification) => {
112114 ref,
113115 onLayout,
114116 updateHiddenValueByDirection,
117+ isLayoutReady,
115118 } ;
116119} ;
0 commit comments