Fix duplicate platform labels in UIExplorer examples

Summary:
public
This fixes a bug in UIExplorer, where platform labels on examples like (ios only) or (android only) would be re-appended to the title each time the example was viewed.

Reviewed By: javache

Differential Revision: D2869690

fb-gh-sync-id: 07f3f14007f75eea23a5328b7850f3f620691ac2
This commit is contained in:
Nick Lockwood 2016-01-28 04:06:27 -08:00 committed by facebook-github-bot-3
parent 96a3a8e9b9
commit 4511993ffa
1 changed files with 8 additions and 6 deletions

View File

@ -39,11 +39,13 @@ var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
},
getBlock: function(example: Example, i) {
if (example.platform) {
if (Platform.OS !== example.platform) {
return;
// Filter platform-specific examples
var {title, description, platform} = example;
if (platform) {
if (Platform.OS !== platform) {
return null;
}
example.title += ' (' + example.platform + ' only)';
title += ' (' + platform + ' only)';
}
// Hack warning: This is a hack because the www UI explorer requires
// renderComponent to be called.
@ -74,8 +76,8 @@ var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
return (
<UIExplorerBlock
key={i}
title={example.title}
description={example.description}>
title={title}
description={description}>
{renderedComponent}
</UIExplorerBlock>
);