我正在创建一个React Native应用程序,我想将应用程序的所有内容包装在一个标签中。
我可以用标签包裹每个页面,但这不是一个很干净的解决方案。
#include <iostream>using namespace std;
struct node {
int data;
node* prev;
node* next;
};
node* find(int,node*&);
void afterElement(int,int,node*&,node*&,node* (*find)(int, node*&));
int main() {
node* head = NULL;
node* tail = NULL;
// The program itself has a menu that allows for input of value in list but
// for the sake of relevancy and shortness of code I dropped it out from here
int x, y;
cout << "Insert 2 values: value you wish to insert, and value you wish to insert it after. ";
cin >> x;
cin >> y;
afterElement(x,y,head,tail,find); // modified the passing argument
return 0;
}
node* find(int x,node*& head) {
node* curr = head;
while ((curr != NULL) && (curr->data != x))
curr = curr->next;
return curr;
}
void afterElement(int x,int after,node*& head,node*& tail,node* (*find)(int x, node*& head)) {
node* N;
node* compared = (*find)(after,head);
N->data = x;
if (compared == NULL)
cout << "There is no element " << after << " in the list!\n";
else {
if (compared->next == NULL) {
compared->next = N;
N->prev = compared;
N->next = NULL;
tail = N;
} else {
compared->next->prev = N;
N->next = compared->next;
compared->next = N;
N->prev = compared;
}
}
}
我想要的工作是这样的:
const SimpleApp = StackNavigator({
Home: {screen: HomeScreen},
...
});
AppRegistry.registerComponent('AFApplication', () => SimpleApp);
当然,代码是无效的,但是我想知道是否有一种方法可以达到预期的效果。
答案 0 :(得分:2)
我认为您需要这样的东西:
const AppContainer = createAppContainer(AppNavigator);
export default class App extends React.Component {
render() {
return <AppContainer />;
}
}
如果是的话,请检查react-navigation在项目中的设置。
祝你好运!