question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Screen freeze after update FlatList data and go back

See original GitHub issue

Description

Screen freeze after updating FlatList data and return to the previous screen

App does not freeze when:

  1. Used ScrollView instead FlastList or
  2. Downgrade react-native-screens to 2.18.0 or
  3. Add detachInactiveScreens={false} for Stack Navigator

Screenshots

https://user-images.githubusercontent.com/14233750/152067342-08ee546b-dd1c-462f-9c28-d0ebebc0d954.mp4

Steps To Reproduce

  1. Create 2 Stack Screens
  2. Go to Second Screen which display FlastList
  3. Add new item to FlatList
  4. 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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
totodotcommented, Feb 16, 2022

Update react-native-reanimated to 2.4.1 resolved the problem

0reactions
anhnchcommented, Dec 6, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found