File tree Expand file tree Collapse file tree
src/components/KeyboardAvoidingView Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ const KeyboardAvoidingView = forwardRef<
9292 ref ,
9393 ) => {
9494 const initialFrame = useSharedValue < LayoutRectangle | null > ( null ) ;
95- const internalRef = React . useRef < View > ( null ) ;
95+ const internalRef = React . useRef < View | null > ( null ) ;
9696 const frame = useDerivedValue ( ( ) => initialFrame . value || defaultLayout ) ;
9797
9898 const { translate, padding } = useTranslateAnimation ( ) ;
@@ -209,11 +209,15 @@ const KeyboardAvoidingView = forwardRef<
209209 } , [ behavior , enabled , interpolateToRelativeKeyboardHeight ] ) ;
210210 const combinedRef = useCallback (
211211 ( node : View | null ) => {
212- ( internalRef as React . MutableRefObject < View | null > ) . current = node ;
212+ internalRef . current = node ;
213213
214- if ( typeof ref === "function" ) ref ( node ) ;
215- else if ( ref )
214+ if ( typeof ref === "function" ) {
215+ ref ( node ) ;
216+ } else if ( ref != null && "current" in ref ) {
217+ // ForwardedRef includes RefObject whose .current is readonly in TS,
218+ // but React always passes a mutable ref object at runtime.
216219 ( ref as React . MutableRefObject < View | null > ) . current = node ;
220+ }
217221 } ,
218222 [ ref ] ,
219223 ) ;
You can’t perform that action at this time.
0 commit comments