From dad462258fae332f276d9a256892cc5fe9fe0c14 Mon Sep 17 00:00:00 2001 From: asmockler Date: Mon, 25 Jan 2016 06:00:26 -0800 Subject: [PATCH] Ensure perspective value is non-zero Summary: Setting `transform: {perspective: 0}` was causing app failure due to `NaN` produced by divide by zero in [MatrixMath.js](https://github.com/facebook/react-native/blob/96553cf553e26e48a87f83030e04aef788f2dfef/Libraries/Utilities/MatrixMath.js#L118). See issue #2616 Closes https://github.com/facebook/react-native/pull/5457 Reviewed By: svcscm Differential Revision: D2851748 Pulled By: bestander fb-gh-sync-id: d2872fb73b4d95ba0b6e5ed2bee814158645cf73 --- Libraries/StyleSheet/processTransform.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Libraries/StyleSheet/processTransform.js b/Libraries/StyleSheet/processTransform.js index 4666a30552..4a523f9091 100644 --- a/Libraries/StyleSheet/processTransform.js +++ b/Libraries/StyleSheet/processTransform.js @@ -165,6 +165,20 @@ function _validateTransform(key, value, transformation) { stringifySafe(transformation), ); break; + case 'perspective': + invariant( + typeof value === 'number', + 'Transform with key of "%s" must be a number: %s', + key, + stringifySafe(transformation), + ); + invariant( + value !== 0, + 'Transform with key of "%s" cannot be zero: %s', + key, + stringifySafe(transformation), + ); + break; default: invariant( typeof value === 'number',