Skip to content

Commit b2196c1

Browse files
author
Pavlo Aksonov
committed
fix minification bug with latest React 0.10.1
1 parent 693e611 commit b2196c1

File tree

6 files changed

+204
-65
lines changed

6 files changed

+204
-65
lines changed

Example/.idea/workspace.xml

Lines changed: 156 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/iOS/AppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
4343
* see http://facebook.github.io/react-native/docs/runningondevice.html
4444
*/
4545

46-
// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
46+
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
4747

4848
RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation moduleProvider:nil launchOptions:launchOptions];
4949
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"Example"];

Example/iOS/main.jsbundle

Lines changed: 19 additions & 19 deletions
Large diffs are not rendered by default.

Example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"start": "node_modules/react-native/packager/packager.sh"
77
},
88
"dependencies": {
9-
"react-native": "^0.9.0",
9+
"react-native": "^0.10.1",
1010
"react-native-button": "^1.2.1",
1111
"react-native-navbar": "^0.8.0",
1212
"react-native-router-flux": "^0.1.0"

index.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,42 @@ var FetchStore = require('./FetchStore');
99
var Animations = require('./Animations');
1010

1111
// schema class represents schema for routes and it is processed inside Router component
12-
var Schema = React.createClass({
12+
class Schema extends React.Component {
1313
render(){
1414
return null;
1515
}
16-
});
16+
}
1717

1818
// schema class represents fetch call
19-
var API = React.createClass({
19+
class API extends React.Component {
2020
render(){
2121
return null;
2222
}
23-
});
23+
}
2424

2525
// route class processed inside Router component
26-
var Route = React.createClass({
26+
class Route extends React.Component {
2727
render(){
2828
return null;
2929
}
3030

31-
});
31+
}
32+
33+
/* Returns the class name of the argument or undefined if
34+
it's not a valid JavaScript object.
35+
*/
36+
function getClassName(obj) {
37+
if (obj.toString) {
38+
var arr = obj.toString().match(
39+
/function\s*(\w+)/);
40+
41+
if (arr && arr.length == 2) {
42+
return arr[1];
43+
}
44+
}
45+
46+
return undefined;
47+
}
3248

3349
class Router extends React.Component {
3450
constructor(props){
@@ -89,15 +105,15 @@ class Router extends React.Component {
89105

90106
// iterate schemas
91107
React.Children.forEach(this.props.children, function (child, index){
92-
if (child.type.displayName == 'Schema') {
108+
if (child.type.name == getClassName(Schema)) {
93109
var name = child.props.name;
94110
self.schemas[name] = child.props;
95111
}
96112
});
97113

98114
// iterate routes
99115
React.Children.forEach(this.props.children, function (child, index){
100-
if (child.type.displayName == 'Route') {
116+
if (child.type.name == getClassName(Route)) {
101117
var name = child.props.name;
102118
self.routes[name] = child.props;
103119
if (child.props.initial || !initial || name==self.props.initial) {
@@ -119,7 +135,7 @@ class Router extends React.Component {
119135

120136
// iterate fetches
121137
React.Children.forEach(this.props.children, function (child, index){
122-
if (child.type.displayName == 'API') {
138+
if (child.type.name == getClassName(API)) {
123139
var name = child.props.name;
124140
self.apis[name] = child.props;
125141

@@ -207,7 +223,7 @@ class Router extends React.Component {
207223
</View>
208224
);
209225
} else {
210-
return <View/>
226+
return <View style={styles.container}><Text>No initial route</Text></View>
211227
}
212228

213229
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-router-flux",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "React Native Router using Flux architecture",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)