我是 React 的新手,并试图遵循本教程。显然,它适用于旧版本的 react-native。所以我在代码不起作用时跟踪并调整代码。我正在使用ReactNative 0.41
.
我的 index.ios.js:
import React, { Component } from 'react';
import {
AppRegistry,
TabBarIOS
} from 'react-native';
import Featured from './Featured';
import Search from './Search';
class BookSearch extends Component {
constructor(props) {
super(props);
this.state = {
selectedTab: 'featured'
};
}
render() {
return (
<TabBarIOS selectedTab={this.state.selectedTab}>
<TabBarIOS.Item
selected={this.state.selectedTab === 'featured'}
icon={{uri:'featured'}}
onPress={() => {
this.setState({
selectedTab: 'featured'
});
}}>
<Featured/>
</TabBarIOS.Item>
<TabBarIOS.Item
selected={this.state.selectedTab === 'search'}
icon={{uri:'search'}}
onPress={() => {
this.setState({
selectedTab: 'search'
});
}}>
<Search/>
</TabBarIOS.Item>
</TabBarIOS>
);
}
}
AppRegistry.registerComponent('BookSearch', () => BookSearch);
这是错误: