Skip to content

Instantly share code, notes, and snippets.

/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @providesModule WindowedListView
* @flow
*/
'use strict';
var React = require('React');
var ScrollView = require('ScrollView');
@sahrens
sahrens / ViewabilityHelper.js
Created December 15, 2015 21:56
Helper class for WindowedListView
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @providesModule ViewabilityHelper
* @flow
*/
'use strict';
const ViewabilityConsts = {
VIEWABLE_PERCENT_THRESHOLD: 50,

A Better ListView for React Native

I have a proposal for some new APIs, and a first draft on an implementation (first diff: D4412469). Salient points on the new APIs:

  • Two easy-to-use components: FlatList and SectionList. I have found that separating the section API out makes things a lot cleaner for both cases.

  • One shared underlying implementation, VirtualizedList, which has an API similar to react-virtualized and uses getter functions to be very flexible and supports any kind of data structure such as a plain array or an immutable list.

  • Naming adjustments to make it horizontal agnostic, e.g. "Item" instead of "Row".

@sahrens
sahrens / gist:b3b2c615b5c62d018d15c2c43b6f903d
Created September 1, 2017 18:45
Sticky Headers Jittery on Android repro
ScreenCast from physical Pixel device: https://youtu.be/D7FO0D9YNFE
const FlatList = require('FlatList');
const React = require('React');
const Text = require('Text');
const View = require('View');
function renderList(): React.Node {
const makeBar = (color, text) => () =>
<View