Screen freeze after update FlatList data and go back
See original GitHub issueDescription
Screen freeze after updating FlatList data and return to the previous screen
App does not freeze when:
- Used ScrollView instead FlastList or
- Downgrade react-native-screens to 2.18.0 or
- Add
detachInactiveScreens={false}
for Stack Navigator
Screenshots
Steps To Reproduce
- Create 2 Stack Screens
- Go to Second Screen which display FlastList
- Add new item to FlatList
- Go back to First Screen
Expected behavior
First Screen not freeze
Actual behavior
First screen freeze, and cannot click on button
Reproduction
const First = ({ navigation }) => {
return (
<View>
<Button title="click" onPress={() => navigation.navigate('Second')} />
</View>
);
};
const Second = ({ navigation }) => {
const [numbers, setNumbers] = useState([1, 2, 3]);
return (
<View>
<FlatList data={numbers} renderItem={({ item }) => <Text>{item}</Text>} />
<Button title="add" onPress={() => setNumbers((a) => [...a, 1])} />
<Button title="back" onPress={() => navigation.goBack()} />
</View>
);
};
const RootNavigation: React.FC = () => {
const RootStack = createStackNavigator();
return (
<NavigationContainer>
<RootStack.Navigator>
<RootStack.Screen name="First" component={First} />
<RootStack.Screen name="Second" component={Second} />
</RootStack.Navigator>
</NavigationContainer>
);
};
export default RootNavigation;
Platform
- iOS
- Android
- Web
- Windows
- tvOS
3.
package | version |
---|---|
react-native | 0.66.3 |
@react-navigation/native | 6.0.6 |
@react-navigation/stack | 6.0.11 |
react-native-screens | 3.10.2 |
react-native-safe-area-context | 3.3.2 |
react-native-gesture-handler | 1.10.3 |
react-native-reanimated | 2.3.0-beta.3 |
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:9 (4 by maintainers)
Top Results From Across the Web
FlatList React Native 0.60 Android Blank and Freezes
In Android using RN 0.60.0 or above FlatList is always blank and sometimes freezes the app even though I can see my data...
Read more >Optimizing Flatlist Configuration - React Native
Move out the renderItem function to the outside of render function, so it won't recreate itself each time render function called. ... );....
Read more >Common bugs in React Native ScrollView and how to fix them
React Native's ScrollView component is ubiquitous, but its implementation can sometimes lead to mistakes. Learn what to look out for here.
Read more >Vertical and Horizontal Scrolling in a SectionList/FlatList
The problem with just doing this is that we render the section's data both horizontally and vertically. Therefore we need to disable the ......
Read more >Flatlist crashes with one component but not with another - Reddit
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your...
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 Free
Top 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
Update react-native-reanimated to 2.4.1 resolved the problem
I confirm tododot’s info 2. Downgrade react-native-screens to 2.18.0 3. Add detachInactiveScreens={false} for Stack Navigator
This is definitely a bug or the 3 points should be written in the official documents. I hope someone can fix it.