Make component registration in UIExplorerApp explicit

Summary: Currently, the components get registered by `UIExplorerApp.ios.js` as a side effect of requiring `UIExplorerList.ios.js`. This removes the side effect and makes the registration explicit so that it works well with inline requires.

public

Reviewed By: jingc

Differential Revision: D2613174

fb-gh-sync-id: 799dd8b11985708b05fc4c03f367487b47f46bc6
This commit is contained in:
Bhuwan Khattar 2015-11-03 17:10:15 -08:00 committed by facebook-github-bot-5
parent 2519d25992
commit db229aab87
2 changed files with 20 additions and 17 deletions

View File

@ -73,5 +73,6 @@ var styles = StyleSheet.create({
});
AppRegistry.registerComponent('UIExplorerApp', () => UIExplorerApp);
UIExplorerList.registerComponents();
module.exports = UIExplorerApp;

View File

@ -79,23 +79,6 @@ var APIS = [
require('./ImageEditingExample'),
];
// Register suitable examples for snapshot tests
COMPONENTS.concat(APIS).forEach((Example) => {
if (Example.displayName) {
var Snapshotter = React.createClass({
render: function() {
var Renderable = UIExplorerListBase.makeRenderable(Example);
return (
<SnapshotViewIOS>
<Renderable />
</SnapshotViewIOS>
);
},
});
AppRegistry.registerComponent(Example.displayName, () => Snapshotter);
}
});
type Props = {
navigator: {
navigationContext: NavigationContext,
@ -144,6 +127,25 @@ class UIExplorerList extends React.Component {
onPressRow(example: any) {
this._openExample(example);
}
// Register suitable examples for snapshot tests
static registerComponents() {
COMPONENTS.concat(APIS).forEach((Example) => {
if (Example.displayName) {
var Snapshotter = React.createClass({
render: function() {
var Renderable = UIExplorerListBase.makeRenderable(Example);
return (
<SnapshotViewIOS>
<Renderable />
</SnapshotViewIOS>
);
},
});
AppRegistry.registerComponent(Example.displayName, () => Snapshotter);
}
});
}
}
var styles = StyleSheet.create({