From 153661279c8b980256a6c84c574dca02e6b74791 Mon Sep 17 00:00:00 2001 From: James Ide Date: Thu, 25 Jun 2015 14:14:32 -0700 Subject: [PATCH] [ListView] Defer measurement one frame after componentDidMount to fix error When `UIManager.measure` is called from `componentDidMount` it causes the error "Attempted to measure layout but offset or dimensions were NaN". Deferring the layout by one frame solves this problem. Layout measurement is already asynchronous anyway, so I believe adding the `requestAnimationFrame` call doesn't affect the program's correctness. Test Plan: Load UIExplorer and no longer get a redbox that says "Attempted to measure layout but offset or dimensions were NaN". --- Libraries/CustomComponents/ListView/ListView.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/CustomComponents/ListView/ListView.js b/Libraries/CustomComponents/ListView/ListView.js index dda32340c22fab..cebfac68e994e5 100644 --- a/Libraries/CustomComponents/ListView/ListView.js +++ b/Libraries/CustomComponents/ListView/ListView.js @@ -276,7 +276,9 @@ var ListView = React.createClass({ }, componentDidUpdate: function() { - this._measureAndUpdateScrollProps(); + this.requestAnimationFrame(() => { + this._measureAndUpdateScrollProps(); + }); }, onRowHighlighted: function(sectionID, rowID) {