环境配置
「
node -v
v7.2.0
react-native-cli: 1.3.0
react-native: 0.39.2
」
源代码
「
/**
- Sample React Native App
- https://github.com/facebook/react-native
-
@flow
*/
var React = require(‘react’)
var Component = React.Component
var AppRegistry = React.AppRegistry
var StyleSheet = React.StyleSheet
var Text = React.Text
var View = React.View
var TabBarIOS = React.TabBarIOS
var 001 = React.createClass({
getInitialState:function() {
console.log(‘child’,‘getDefaultProps’)
return
{
times:this.props.times
}
},
_renderContent: function(color: string, pageText: string, num?: number) {
return (
<View style={[styles.tabContent, {backgroundColor: color}]}>
{pageText}
{num} re-renders of the {pageText}
);
},
render: function() {
return (
<TabBarIOS
unselectedTintColor="yellow"
tintColor="white"
barTintColor="darkslateblue">
<TabBarIOS.Item
icon={{uri: base64Icon, scale: 3}}
selected={this.state.selectedTab === 'blueTab'}
onPress={() => {
this.setState({
selectedTab: 'blueTab',
});
}}>
{this._renderContent('#414A8C', 'Blue Tab')}
</TabBarIOS.Item>
<TabBarIOS.Item
systemIcon="history"
badge={5}
selected={this.state.selectedTab === 'redTab'}
onPress={() => {
this.setState({
selectedTab: 'redTab',
notifCount: this.state.notifCount + 1,
});
}}>
{this._renderContent('#783E33', 'Red Tab', this.state.notifCount)}
</TabBarIOS.Item>
<TabBarIOS.Item
icon={require('./flux.png')}
selectedIcon={require('./relay.png')}
renderAsOriginal
title="More"
selected={this.state.selectedTab === 'greenTab'}
onPress={() => {
this.setState({
selectedTab: 'greenTab',
presses: this.state.presses + 1
});
}}>
{this._renderContent('#21551C', 'Green Tab', this.state.presses)}
</TabBarIOS.Item>
</TabBarIOS>
);
}
})
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: ‘center’,
alignItems: ‘center’,
backgroundColor: ‘#F5FCFF’,
},
welcome: {
fontSize: 20,
textAlign: ‘center’,
margin: 10,
},
instructions: {
textAlign: ‘center’,
color: ‘#333333’,
marginBottom: 5,
},
})
AppRegistry.registerComponent(‘001’, () => 001);
」
报错:
Unhandled JS Exception: ReferenceError
loadModuleImplementation
index.ios.bundle?platform=ios&dev=true&minify=false:188:8
loadModuleImplementation
index.ios.bundle?platform=ios&dev=true&minify=false:188:8
loadModuleImplementation
index.ios.bundle?platform=ios&dev=true&minify=false:188:8
loadModuleImplementation
index.ios.bundle?platform=ios&dev=true&minify=false:188:8
loadModuleImplementation
index.ios.bundle?platform=ios&dev=true&minify=false:188:8
loadModuleImplementation
index.ios.bundle?platform=ios&dev=true&minify=false:188:8
guardedLoadModule
index.ios.bundle?platform=ios&dev=true&minify=false:133:37
global code
index.ios.bundle?platform=ios&dev=true&minify=false:5457:9