Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native SectionList replace data key

I am fairly new to React and React native, but I have bumped into a problem when populating a SectionList and could not find a solution yet.

I have an array of objects, and each object has it's own array. A SectionList is ideal to display this info, however, the array for each section is not called "data", while SectionList seems to expect the key "data" for the array in each section.

Is there a way to tell the SectionList to use another key instead of the data key to populate each section's array?

like image 950
Steve Scerri Avatar asked Nov 08 '22 04:11

Steve Scerri


1 Answers

As Per my Knowledge on SectionList each Section will Expect a data and Key .

What you can do is modify your Data as per that.

like for Eg : your data is [[1,2,3],[4,5],[6,7]]

what you can do is iterate through this array and push each subArray into New Array With Format {key:index,data:subArray}

hope this will Help :)

like image 140
RishabhRathod Avatar answered Nov 15 '22 06:11

RishabhRathod