KeyboardAvoidingView flickering and hangs with Expo SDK 40, React Navigation, and even with latest react-native-screens@^2.16.0
See original GitHub issueDescription
I recently upgraded to Expo SDK 40 and started experiencing extreme glitches with KeyboardAvoidingView. In a couple of cases, the phone became completely unresponsive and had to be hard-restarted. I isolated it to the interaction of React Navigation and react-native-screens. Expo forces react-native-screens@2.15 but explicitly upgrading with yarn add react-native-screens@^2.16.1
doesn’t help.
Commenting out these two lines resolves the issue:
import { enableScreens } from 'react-native-screens';
enableScreens();
Only tested/reproduced on iPhone.
Screenshots
Steps To Reproduce
- Click TextInput
- Observe keyboard flickering
Snack or minimal code example
The issue doesn’t reproduce on Snack seemingly because Snack still uses Expo SDK 39. You can reproduce locally with:
git clone https://github.com/kevgrig/rnkavflicker
expo start
import React from 'react';
import { KeyboardAvoidingView, ScrollView, TextInput } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { enableScreens } from 'react-native-screens';
enableScreens();
const AppStack = createStackNavigator();
function Screen1() {
const [value, onChangeText] = React.useState('');
return (
<ScrollView contentContainerStyle={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<TextInput
placeholder='Input'
style={{ borderWidth: 1, width: '75%', padding: 10 }}
onChangeText={text => onChangeText(text)}
value={value}
/>
</ScrollView>
);
}
const USE_REACT_NAVIGATION = true;
export default class App extends React.Component {
render() {
return (
<KeyboardAvoidingView behavior='padding' style={{ flex: 1 }}>
{
USE_REACT_NAVIGATION ?
<NavigationContainer>
<AppStack.Navigator>
<AppStack.Screen name='App' component={Screen1} />
</AppStack.Navigator>
</NavigationContainer>
:
<Screen1 />
}
</KeyboardAvoidingView>
);
}
}
Package versions
- React: 16.13.1
- React Native: 0.63.2
- React Native Screens: 2.16.1
- React Navigation/stack: 5.12.8
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
KeyboardAvoidingView flickering and hangs with Expo SDK ...
KeyboardAvoidingView flickering and hangs with Expo SDK 40, React ... even after moving KeyboardAvoidingView lower, that app still has react navigation.
Read more >My header title flickering in react native expo when keyboard ...
EDIT: i found a solutions for this problem. adding this in StackNavigator headerForceInset:{top:'never' , bottom:'never'} solved the ...
Read more >React Native Fix: Jumping Screens in the React-Navigation ...
The issue was that every time I selected a new tab of the tab navigator, the screen would “jump” as it was rendering....
Read more >react-native-modal-keyboardavoidingview-issue - Expo Snack
Try this project on your phone! Use Expo's online editor to make changes and save your own copy.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Note for anyone else hitting this that, in testing my more complicated application, moving
KeyboardAvoidingView
inside ofNavigationContainer
did not help and commenting out the twoenableScreens
lines was still the only workaround.As per Expo issue 11326, the native fix was backported and everything works now. Thanks!