FaridSafi / FaridSafi/react-native-gifted-listview

Incorrect merge behavior for data with existing sections

Open
#98 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.6k
Forks
287
PR merge metrics
No merged PRs in 30d

Description

Current implementation of `MergeRecursive` function works incorrectly when loading a new page with header that already exists, new data completely overwrites old.
Consider the following example:

```
const a = { monday: ['a', 'b', 'c'] };
const b = { monday: ['d', 'e'], tuesday: ['f'] };
MergeRecursive(a, b);
```
gives
```
{ monday: [ 'd', 'e' ], tuesday: [ 'f' ] }
```
instead of expected
```
{ monday: ['a', 'b', 'c', 'd', 'e' ], tuesday: [ 'f' ] }
```

so to get this feature work correctly we need either prefetch all pages before current too, which
is totally inefficient of course or to merge new data with old before passing it to the `callback`
which is not so convenient.

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the MergeRecursive function and the page-loading path that passes data to the callback. Reproduce the monday/tuesday example and inspect how an existing section is handled when new data arrives. Done means existing array values are retained and new values are added while new sections still appear in the result.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.