我第一次学习反应原生。我开始实现文档中定义的教程,但是我收到了一个错误,我也搜索了它,但没有对我有用。
这是我的index.ios.js文件:
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
//import React,
var {
AppRegistry,
Component,
Image,
StyleSheet,
Text,
View
} = React;
var mocked_movies_data = [{title: 'Title', year:'2016', posters: {thumbnail: 'http://i.imgur.com/UePbdph.jpg'}},];
class DemoApp extends Component {
render()
{
var movie = mocked_movies_data[0];
return (
<View style = {styles.container}>
<Text style = {movie.title}></Text>
<Text style = {movie.year}></Text>
<Image source = {{uri:movie.posters.thumbnail}}
style = {styles.thumbnail} />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex:1,
justifyContent:'center',
alignItems: 'center',
backgroundColor: '#F5FCFF'
},
thumbnail: {
width: 53,
height: 81
}
});
AppRegistry.registerComponent('DemoApp', () => DemoApp);
我收到了这个错误:
无法执行js调用:_fbBatchedBridge未定义
答案 0 :(得分:3)
我得到了解决方案:
在代码的顶部,我只需添加以下行:
var React = require(&#39; react-native&#39;);