boredgames
boredgames

Reputation: 11600

ListView section data (react-native)

I'd like to create a two-tier (section >> entry) listview in react-native similar to ListViewPagingExample from UIExplorerApp but using blob data / json to populate sections info. Also, I'm confused as to what parameter values to pass on to cloneWithRowsAndSections.

Can't find anything regarding the above topic from docs (https://facebook.github.io/react-native/docs/listview.html#content) but only the mention that it is possible. Some examples would be helpful.

Thank you

Upvotes: 2

Views: 2752

Answers (1)

Colin Ramsay
Colin Ramsay

Reputation: 16466

You can find the source code for ListViewDataSource here.

The cloneWithRows method is defined as:

cloneWithRows(
    dataBlob: Array<any> | {[key: string]: any},
    rowIdentities: ?Array<string>
)

Whereas cloneWithRowsAndSections is:

cloneWithRowsAndSections( dataBlob: any, sectionIdentities: ?Array, rowIdentities: ?Array> )

The sectionIdentities parameter is documented as:

This is an array of identifiers for sections. ie. ['s1', 's2', ...]. If not provided, it's assumed that the keys of dataBlob are the section identities.

Upvotes: 1

Related Questions