Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListView - Data structure for renderSectionHeader #955

Closed
Ehesp opened this issue Apr 21, 2015 · 4 comments
Closed

ListView - Data structure for renderSectionHeader #955

Ehesp opened this issue Apr 21, 2015 · 4 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@Ehesp
Copy link
Contributor

Ehesp commented Apr 21, 2015

I'm currently struggling to understand how to get the section headers working. My data structure is like so:

[{
    title: 'Header One',
    data: []
}, {
    title: 'Header Two',
    data: []   
}]

Where data is an array of objects.

    renderSectionHeader(sectionData, sectionID) {
        console.log('Section ID:', sectionID);
        console.log('Section Data:', sectionData);

This just returns s1 and the whole data set. How do I specify/break-up this data?

I've tried looking at the examples, but I'm finding it hard to see what the structure is like.

@sahrens
Copy link
Contributor

sahrens commented Apr 24, 2015

I think the problem might be that you're mixing and matching. Can you try either doing an array of arrays, or an object of objects, instead of the array of objects that you have there? Here's the comment from ListViewDataSource:

   * The default extractor expects data of one of the following forms:
   *
   *      { sectionID_1: { rowID_1: <rowData1>, ... }, ... }
   *
   *    or
   *
   *      [ [ <rowData1>, <rowData2>, ... ], ... ]

@sahrens
Copy link
Contributor

sahrens commented Apr 24, 2015

If you want to keep your data structured the way it currently is (or if you can't get it working otherwise), you'll need to provide your own sectionIdentities, and rowIdentities arrays when you clone the datasource, and might want to provide your own extractors as well.

@sahrens
Copy link
Contributor

sahrens commented Apr 27, 2015

Let me know if this doesn't work for you.

@sahrens sahrens closed this as completed Apr 27, 2015
@jasonmerino
Copy link

For anyone who runs across this issue with the same question I had it looks like there is another data format the extractor accepts now. Here is the list of accepted formats from the ListViewDataSource.js comments.

   * The default extractor expects data of one of the following forms:
   *
   *      { sectionID_1: { rowID_1: <rowData1>, ... }, ... }
   *
   *    or
   *
   *      { sectionID_1: [ <rowData1>, <rowData2>, ... ], ... }
   *
   *    or
   *
   *      [ [ <rowData1>, <rowData2>, ... ], ... ]

@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants