mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: The `onLayout` handler of the `KeyboardAvoidingView` view is async due to the `await AccessibilityInfo.prefersCrossFadeTransitions` in `_relativeKeyboardHeight`. A connected `onLayout` handler will be unable to access the event. Call `persist()` on the event so that it can be accessed asynchronously. ## Changelog: [GENERAL] [FIXED] - Accessing KeyboardAvoidingEvent event in onLayout handler Pull Request resolved: https://github.com/facebook/react-native/pull/47798 Test Plan: The following should not produce an error: ``` import * as React from 'react'; import { KeyboardAvoidingView, SafeAreaView, TextInput } from 'react-native'; export default function() { return ( <SafeAreaView> <KeyboardAvoidingView onLayout={(event) => console.log(event)} behavior="padding"> <TextInput /> </KeyboardAvoidingView> </SafeAreaView> ); } ``` Reviewed By: cipolleschi Differential Revision: D66306085 Pulled By: dmytrorykun fbshipit-source-id: 9ccf00db79947670ddc7de74a47cc6dc27455fc0