From 5b2d8000ae189b76888b40bafef1302b08ecb9b5 Mon Sep 17 00:00:00 2001 From: Andrei Coman Date: Tue, 1 Sep 2015 05:08:25 -0700 Subject: [PATCH] [ReactNative][SyncDiff] Add option to make examples platform specific --- Examples/UIExplorer/ExampleTypes.js | 2 ++ Examples/UIExplorer/createExamplePage.js | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/Examples/UIExplorer/ExampleTypes.js b/Examples/UIExplorer/ExampleTypes.js index 44db06a6c..ac9deaadf 100644 --- a/Examples/UIExplorer/ExampleTypes.js +++ b/Examples/UIExplorer/ExampleTypes.js @@ -14,11 +14,13 @@ * @providesModule ExampleTypes * @flow */ +'use strict'; export type Example = { title: string, render: () => ?ReactElement, description?: string, + platform?: string; }; export type ExampleModule = { diff --git a/Examples/UIExplorer/createExamplePage.js b/Examples/UIExplorer/createExamplePage.js index 86525c485..410688160 100644 --- a/Examples/UIExplorer/createExamplePage.js +++ b/Examples/UIExplorer/createExamplePage.js @@ -17,6 +17,9 @@ 'use strict'; var React = require('react-native'); +var { + Platform, +} = React; var ReactNative = require('ReactNative'); var UIExplorerBlock = require('./UIExplorerBlock'); var UIExplorerPage = require('./UIExplorerPage'); @@ -36,6 +39,12 @@ var createExamplePage = function(title: ?string, exampleModule: ExampleModule) }, getBlock: function(example: Example, i) { + if (example.platform) { + if (Platform.OS !== example.platform) { + return; + } + example.title += ' (' + example.platform + ' only)'; + } // Hack warning: This is a hack because the www UI explorer requires // renderComponent to be called. var originalRender = React.render;