mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 17:45:59 +00:00
39f475ea9b
- Random little fixes | Andres Suarez - Add backButtonTitle to Navigator | Nick Poulden - [react-pacakger] Ignore malformed package.json | Amjad Masad - Renamed hasMove to hasMark | Rich Seymour - Update XMLHttpRequest.ios.js | Nick Poulden - Warn about missing dependencies for issue #16 | Andrew McCloud
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
/**
|
|
* Copyright 2004-present Facebook. All Rights Reserved.
|
|
*
|
|
* @providesModule createExamplePage
|
|
*/
|
|
'use strict';
|
|
|
|
var React = require('react-native');
|
|
var UIExplorerBlock = require('./UIExplorerBlock');
|
|
var UIExplorerPage = require('./UIExplorerPage');
|
|
|
|
var invariant = require('invariant');
|
|
|
|
var createExamplePage = function(title, exampleModule) {
|
|
invariant(!!exampleModule.examples, 'The module must have examples');
|
|
|
|
var ExamplePage = React.createClass({
|
|
statics: {
|
|
title: exampleModule.title,
|
|
description: exampleModule.description,
|
|
},
|
|
|
|
getBlock: function(example, i) {
|
|
// Hack warning: This is a hack because the www UI explorer requires
|
|
// renderComponent to be called.
|
|
var originalRenderComponent = React.renderComponent;
|
|
var originalRender = React.render;
|
|
var renderedComponent;
|
|
React.render = React.renderComponent = function(element, container) {
|
|
renderedComponent = element;
|
|
};
|
|
var result = example.render(null);
|
|
if (result) {
|
|
renderedComponent = result;
|
|
}
|
|
React.renderComponent = originalRenderComponent;
|
|
React.render = originalRender;
|
|
return (
|
|
<UIExplorerBlock
|
|
key={i}
|
|
title={example.title}
|
|
description={example.description}>
|
|
{renderedComponent}
|
|
</UIExplorerBlock>
|
|
);
|
|
},
|
|
|
|
render: function() {
|
|
return (
|
|
<UIExplorerPage title={title}>
|
|
{exampleModule.examples.map(this.getBlock)}
|
|
</UIExplorerPage>
|
|
);
|
|
}
|
|
});
|
|
|
|
return ExamplePage;
|
|
};
|
|
|
|
module.exports = createExamplePage;
|