在我的 React 原生应用程序中,我使用的是“react-navigation”:“^3.11.0”。我有顶级bottomTabNavigator
const TabNavigator = createBottomTabNavigator({
Main: {
screen: balanceStack,
navigationOptions: {
tabBarLabel: I18n.t("balanceTabLabel"),
tabBarIcon: ({ tintColor}: {tintColor: string}) => (
<Icon name="home" style={{color: tintColor}} />
)
}
},
ServicesStack: {
screen: servicesStack,
navigationOptions: {
tabBarLabel: I18n.t("servicesTabLabel"),
tabBarIcon: ({ tintColor}: {tintColor: string}) => (
<Icon name="list-box" style={{color: tintColor}} />
)
}
},
}, {
tabBarOptions: {
activeTintColor: WHITE_COLOR,
inactiveTintColor: WHITE_COLOR,
style: {
backgroundColor: PRIMARY_COLOR,
}
},
backBehavior: 'history',
swipeEnabled: true,
});
Run Code Online (Sandbox Code Playgroud)
每个选项卡的堆栈导航器:
const balanceStack = createStackNavigator({
Balance: {
screen: …Run Code Online (Sandbox Code Playgroud) 我在我的 React 本机应用程序中使用领域,尝试从领域数据库查询对象列表。
function* loadPlaces() {
let realm;
try {
const filter = yield select(getFilter);
realm = yield call(Realm.open, {schema: [PlaceSchema]});
let places = realm.objects(PlaceSchema.name);
if (filter.search) {
places = places.filtered("name CONTAINS $0", filter.search);
}
switch (filter.sort) {
case Sort.BY_NAME:
places = places.sorted('name');
break;
}
yield put(loadPlacesSucceed(places));
} catch (e) {
console.warn(e.message);
} finally {
if (realm) {
realm.close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
之后,我在 flatlist 中使用结果数据:
<FlatList
data={this.props.items}
keyExtractor={(item) => '' + item.id}
renderItem={({item}) =>
<PlaceItem item={item} onClick={(item) => this._onItemClicked(item)}/>}/>
Run Code Online (Sandbox Code Playgroud)
并收到错误: …