尝试移动应用程序入口点不起作用EXPO

问题描述

我正在尝试在博览会应用程序中创建index.js文件:

import React from 'react';
import { AppRegistry } from 'react-native';
import App from './App';
import { Provider } from 'react-redux'
import { name as appName } from './app.json';
import {Provider} from 'react-redux';
import reducers from './reducers';
import thunk from 'redux-thunk';

let store = createStore(reducers,applyMiddleware(thunk))

const RNRedux = () => {
    <Provider store={store}>
        <App/>
    </Provider>

}

AppRegistry.registerComponent(appName,() => RNRedux);

我这样做是因为我需要访问App.js文件中的商店,并且不断遇到此错误

Error: Could not find "store" in the context of "Connect(App)". Either wrap the root component in a <Provider>,or pass a custom React context provider to <Provider> and the corresponding React context consumer to Connect(App) in connect options.

我也修复了package.json中的主文件,但错误仍然存​​在。对这个问题有什么想法/其他解决方法吗?非常感谢!

解决方法

我想您的应用程序将包含导航文件夹。因此,只需采用这种方式即可。

App.js

import store from './store'

const App = () => {
  render() {
    return (
      <Provider store={store}>
        <Navigation />
      </Provider>
    );
  }
}

export default App;

Store.js

import { createStore } from "redux";
import rootReducer from "../reducers";

const store = createStore(rootReducer)

export default store;

希望它能给您带来灵感

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...