reactjsreact-nativerecyclerlistview

Filter data for RecyclerListView


I'm trying to implement basic list with a filter using RecyclerListView. But as soon as type some text and the scroll is not at the top, it throws exception No layout available for index.

See in this snack https://snack.expo.io/SJY6NU00B

Instructions to reproduce:

  1. Scroll to the bottom
  2. Type letter 'A' in the TextInput

Result :

No layout available for index: 233 LayoutUnavailableException: No layout available for index: 233 at new e (module://recyclerlistview.js:3:1527) at e.getOffsetForIndex (module://recyclerlistview.js:3:5917) at t.refreshWithAnchor (module://recyclerlistview.js:3:26794) at e._checkAndChangeLayouts (module://recyclerlistview.js:3:16117) at e.componentWillReceiveProps (module://recyclerlistview.js:3:11983) at Hi ([snack internals] at ha ([snack internals] at Js ([snack internals] at js ([snack internals] at Ps (https://s3.us-west-1.amazonaws.com/snack-web-player/36/static/js/2.d51b9d02.chunk.js:1:1086639)

Am i doing it wrong?


Solution

  • In the package itself I've done the following:

    Commented out the lines where it throws exception in LayoutManager.js lines: 64-67

    Instead just put return { x: 0, y: 0};

    WrapGridLayoutManager.prototype.getOffsetForIndex = function (index) {
        if (this._layouts.length > index) {
            return { x: this._layouts[index].x, y: this._layouts[index].y };
        }
        else {
            return { x: 0, y: 0};
            // Commented the part that throws exception
            // throw new CustomError_1.default({
            //     message: "No layout available for index: " + index,
            //     type: "LayoutUnavailableException",
            // });
        }
    };
    

    I have opened the issue and it is still not addressed https://github.com/Flipkart/recyclerlistview/issues/446