cooperka / react-native-immutable-list-view

:scroll: Drop-in replacement for ListView, FlatList, and VirtualizedList.
MIT License
205 stars 30 forks source link

Immutable.List of length 0 causes UI to freeze #16

Closed petermikitsh closed 7 years ago

petermikitsh commented 7 years ago

Hello, encountered an interesting bug while using ImmutableVirtualizedList. Add the following stateless, functional component to your render tree, and will bring your react-native app's UI thread to its knees. With no console error, no nothing.

import Immutable from 'immutable';
import ImmutableVirtualizedList from 'react-native-immutable-list-view/lib/ImmutableVirtualizedList';
import React from 'react';

function HomeHelper() {
  const list = new Immutable.List();
  return (
    <ImmutableVirtualizedList
      immutableData={list}
      renderItem={() => (
        <View/>
      )}
    />
  );
}

Currently using these dependency versions:

immutable@3.8.1 react-native@0.43.0-rc.3 react-native-immutable-list-view@0.4.0

ui_broken

Using the accessibility inspector to better illustrate the broken UI. Normally the clicks would switch between tabs.

petermikitsh commented 7 years ago

I wanted to clarify that this use case will reproduce the issue:

const list = new Immutable.List([]);

But this case will not:

const list = new Immutable.List([1]);
cooperka commented 7 years ago

Very weird, I tried this on the example app and got the same problem using RN v0.41.1. Thanks for the bug report! I'll look into it.

cooperka commented 7 years ago

@petermikitsh turns out getItemCount was undefined for empty lists, which somehow caused the UI to freeze up. It's fixed in v0.4.1 now.

petermikitsh commented 7 years ago

Thanks for the quick turnaround, @cooperka!