This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// before running this, define ITEMS as an array of objects whose props you wish to examine | |
items.reduce((tallies, asset) => { | |
Object | |
.keys(asset) | |
.forEach((prop) => { | |
if(tallies.hasOwnProperty(`${prop} (${typeof asset[prop]})`)) { | |
console.log(`has ${prop} (${typeof asset[prop]})`); | |
tallies[`${prop} (${typeof asset[prop]})`] += 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// somewhere, you had to set this up | |
const LVDS = new ListView.DataSource({ | |
getSectionHeaderData: (blob, sectionId) => blob.sectionData[sectionId], | |
getRowData: (blob, sectionId, rowId) => blob.rowData[rowId] | |
}); | |
// ... and then you had to feed data into it with this: | |
let newListData = LVDS.cloneWithRowsAndSections(blob, sectionIds, rowIdsBySection) | |
// but what do blob, sectionIds, and rowIdsBySection look like, and how are they used internally by ListView? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: I'm using a few ES6 features, like Arrow Functions and default argument values | |
// Hopefully they don't trip you up while reading this. | |
import React, { Component, ListView } from 'react-native'; | |
import Moment from 'moment'; // only needed for my example | |
// I reuse this configuration everywhere. As a rule, each component creates just one of them, | |
// and since changing the dataset doesn't require mutating this object, I define it as a const. | |
// |
NewerOlder