Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Function to help format data fetched from the R10 Graphcool API for a React Native SectionList.
// Helper to format GraphQL data into section list data
export const formatSessionData = sessions => {
return sessions
.reduce((acc, curr) => {
const timeExists = acc.find(section => section.title === curr.startTime);
timeExists
? timeExists.data.push(curr)
: acc.push({ title: curr.startTime, data: [curr] });
return acc;
}, [])
.sort((a, b) => a.title - b.title);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.