Invariant Violation: 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.
This error is located at:
in RCTView (at View.js:113)
in View (at AppContainer.js:102)
in RCTView (at View.js:113)
in View (at AppContainer.js:126)
in AppContainer (at renderApplication.js:34)
createFiberFromElementType
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:1016:100
createFiberFromElement
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:996:47
reconcileSingleElement
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:1448:51
reconcileChildFibers
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:1508:63
reconcileChildrenAtPriority
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:1688:78
reconcileChildren
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:1685:40
updateHostComponent
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:1752:39
beginWork
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:1839:43
performUnitOfWork
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:2569:33
workLoop
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:2595:141
_invokeGuardedCallback
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:75:23
invokeGuardedCallback
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:49:40
performWork
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:2634:41
scheduleUpdateImpl
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:2768:101
scheduleUpdate
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:2751:38
scheduleTopLevelUpdate
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:3048:91
updateContainer
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:3059:39
render
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\Renderer\ReactNativeFiber-dev.js:4483:53
renderApplication
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\ReactNative\renderApplication.js:34:4
run
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\ReactNative\AppRegistry.js:117:10
runApplication
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\ReactNative\AppRegistry.js:191:26
__callFunction
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:306:47
<unknown>
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:26
__guard
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:269:6
callFunctionReturnFlushedQueue
D:\learn\React Native\Practice\FirstApp\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:107:17
reducer/index.js
import { combineReducers } from 'redux';
import news from './news/index.js';
const rootReducer = combineReducers({
news
});
export default rootReducer;
sore:
import { createStore,applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from '../reducers/index.js'
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore);
export default function getStore(initialState){
const store = createStoreWithMiddleware(rootReducer, initialState);
return store;
}
root.js
import React from 'react';
import { Provider } from 'react-redux';
import getStore from './store/index.js';
import App from './containers/components/App.js';
const store = getStore();
const Root = () =>
(
<Provider store={store}>
<App/>
</Provider>
);
export default Root;
App.js
const App = DrawerNavigator({
App: {
screen:AppStack,
navigationOptions: {
title: '',
tabBarLabel: '',
},
},
MyScreen: {
screen:MyStack,
},
WelfareStack:{
screen:WelfareStack,
}
},{
drawerWidth:250,
contentComponent: props => <ScrollView><DrawerContent {...props}/></ScrollView>,
contentOptions:{
activeTintColor:'white',
activeBackgroundColor: '#C4C4C4', // 选中背景颜色
inactiveTintColor: '#4F4F4F', // 未选中文字颜色
inactiveBackgroundColor: '#fff', // 未选中背景颜色
}
});
const DrawerContent = (props) => {
return(
<View style={styles.container}>
<View style={styles.header}>
<Image source={require('../../../public/image/2.png')} style={styles.bgimg}>
<Text style={styles.welcome}>欢迎</Text>
</Image>
</View>
<DrawerItems {...props}/>
</View>
)
}
export default App
部分代码