[ReactNative][SyncDiff] Add option to make examples platform specific

This commit is contained in:
Andrei Coman 2015-09-01 05:08:25 -07:00
parent d4e5d95efe
commit 5b2d8000ae
2 changed files with 11 additions and 0 deletions

View File

@ -14,11 +14,13 @@
* @providesModule ExampleTypes
* @flow
*/
'use strict';
export type Example = {
title: string,
render: () => ?ReactElement<any, any, any>,
description?: string,
platform?: string;
};
export type ExampleModule = {

View File

@ -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;