使用Expo成功初始化React-native应用程序的模板构建后,我开始更改为添加自己的模板,包括redux。它返回以下错误(在远程调试窗口中):
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.
Check your code at App.js:10.
in Unknown (created by AwakeInDevApp)
in RCTView (at View.js:514)
in View (created by AwakeInDevApp)
in AwakeInDevApp (at registerRootComponent.js:21)
in ExponentRootComponent (at renderApplication.js:35)
in RCTView (at View.js:514)
in View (at AppContainer.js:93)
in RCTView (at View.js:514)
in View (at AppContainer.js:92)
in AppContainer (at renderApplication.js:34)
reactConsoleErrorHandler @ crna-entry.bundle:6725
newConsoleFunc @ crna-entry.bundle:52943
console.error @ crna-entry.bundle:36227
printWarning @ crna-entry.bundle:3015
warning @ crna-entry.bundle:3036
createElement @ crna-entry.bundle:17021
exports.default @ crna-entry.bundle:81790
(anonymous) @ crna-entry.bundle:21644
measureLifeCyclePerf @ crna-entry.bundle:21459
_constructComponentWithoutOwner @ crna-entry.bundle:21643
_constructComponent @ crna-entry.bundle:21620
mountComponent @ crna-entry.bundle:21513
mountComponent @ crna-entry.bundle:17847
mountChildren @ crna-entry.bundle:21043
initializeChildren @ crna-entry.bundle:20502
mountComponent @ crna-entry.bundle:20562
mountComponent @ crna-entry.bundle:17847
performInitialMount @ crna-entry.bundle:21686
mountComponent @ crna-entry.bundle:21590
mountComponent @ crna-entry.bundle:17847
performInitialMount @ crna-entry.bundle:21686
mountComponent @ crna-entry.bundle:21590
mountComponent @ crna-entry.bundle:17847
performInitialMount @ crna-entry.bundle:21686
mountComponent @ crna-entry.bundle:21590
mountComponent @ crna-entry.bundle:17847
mountChildren @ crna-entry.bundle:21043
initializeChildren @ crna-entry.bundle:20502
mountComponent @ crna-entry.bundle:20562
mountComponent @ crna-entry.bundle:17847
performInitialMount @ crna-entry.bundle:21686
mountComponent @ crna-entry.bundle:21590
mountComponent @ crna-entry.bundle:17847
mountChildren @ crna-entry.bundle:21043
initializeChildren @ crna-entry.bundle:20502
mountComponent @ crna-entry.bundle:20562
mountComponent @ crna-entry.bundle:17847
performInitialMount @ crna-entry.bundle:21686
mountComponent @ crna-entry.bundle:21590
mountComponent @ crna-entry.bundle:17847
performInitialMount @ crna-entry.bundle:21686
mountComponent @ crna-entry.bundle:21590
mountComponent @ crna-entry.bundle:17847
performInitialMount @ crna-entry.bundle:21686
mountComponent @ crna-entry.bundle:21590
mountComponent @ crna-entry.bundle:17847
mountComponentIntoNode @ crna-entry.bundle:22829
perform @ crna-entry.bundle:18133
batchedMountComponentIntoNode @ crna-entry.bundle:22836
perform @ crna-entry.bundle:18133
batchedUpdates @ crna-entry.bundle:17658
batchedUpdates @ crna-entry.bundle:17727
renderComponent @ crna-entry.bundle:22881
render @ crna-entry.bundle:6353
renderApplication @ crna-entry.bundle:49001
run @ crna-entry.bundle:48790
runApplication @ crna-entry.bundle:48830
__callFunction @ crna-entry.bundle:3451
(anonymous) @ crna-entry.bundle:3322
guard @ crna-entry.bundle:3286
callFunctionReturnFlushedQueue @ crna-entry.bundle:3321
(anonymous) @ debuggerWorker.js:71
crna-entry.bundle:6717 Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.
Check the render method of `StatelessComponent`.
handleException @ crna-entry.bundle:6717
handleError @ crna-entry.bundle:6577
reportFatalError @ crna-entry.bundle:683
guard @ crna-entry.bundle:3288
callFunctionReturnFlushedQueue @ crna-entry.bundle:3321
(anonymous) @ debuggerWorker.js:71
crna-entry.bundle:52943 Remote debugger is in a background tab which may cause apps to perform slowly. Fix this by foregrounding the tab (or opening it in a separate window).
newConsoleFunc @ crna-entry.bundle:52943
console.warn @ crna-entry.bundle:36235
(anonymous) @ debuggerWorker.js:25
(anonymous) @ debuggerWorker.js:53
App.js是:
import React from 'react';
import Provider from 'react-redux';
import HomeScreen from './components/HomeScreen';
import createStore from './createStore';
const store = createStore();
export default () => (
<Provider store={store}>
<HomeScreen />
</Provider>
);
完整的代码: https://github.com/wastelandtime/rpgame
请告知。
答案 0 :(得分:1)
在您的App.js中,您将提供程序作为默认模块导入,但实际上它名为export。
所以,改为
import { Provider } from 'react-redux';