3

尝试使用 react-native-navigation 的“startSingleScreenApp”函数初始化 react-native 应用程序时,我看到一条错误消息“应用程序未注册”。

库版本:

反应原生:0.54.0,反应原生导航:1.1.407

我有一个用于导航的根减速器:

export default function createReducer(initialState, handlers) {
return function reducer(state = initialState, action) {
    if (handlers.hasOwnProperty(action.type)) {
        return handlers[action.type](state, action)
    } else {
        return state
    }
}}

export const navigate = createReducer(
Immutable({
    root: undefined
}), {
    [types.NAV__APP_ROOT_CHANGED](state, action) {
        if (state != null) {
            return state.merge({
                root: action.root
            });
        } else {
            return state;
        }
    }
});

注册画面:

export function registerScreens (store, provider) {
Navigation.registerComponent('app.init', () => AppRoot, store, provider);
Navigation.registerComponent('app.login.registration', () => LoginRegistration, store, provider);}

应用入口点:(index.js)

export default class App {
constructor() {
    store.subscribe(this.onStoreUpdate.bind(this));
    store.dispatch(navActions.appInitialized('login'))
}

onStoreUpdate() {
    const {root} = store.getState().navigate;
    if (this.currentRoot != root) {
      this.currentRoot = root;
      this.startApp(root);
    }
}

startApp(root) {
    switch (root) {
        case 'login':
            Navigation.startSingleScreenApp({
                screen: {
                    screen: 'app.init',
                    title: 'App'
               }
           });
           return;
        default:
           return;
    }
}}
const app = new App();

我可以看到商店订阅正在调度和处理的操作,但应用程序没有加载。我只是看到一个错误,说“应用程序”未注册(根 react-native 文件夹是“应用程序”)

任何帮助表示赞赏。谢谢!

4

1 回答 1

0

我有同样的问题,我删除了我的 node_modules 并重新安装,它会有所帮助,但如果添加了新的依赖项,应用程序会再次崩溃。

于 2018-03-26T03:34:20.583 回答