我使用阵营本地为建设Android应用阵营本地组件不工作检查渲染应用
我试图导入组件在index.android.js文件位于app/containers/AppContainer.js。
当运行我得到THI错误的代码:
元类型无效:预期的字符串(用于内置组件)或类/功能(用于复合组件),但得到:未定义。检查的App
渲染方法,这是我的index.android.js文件:
import React, { Component } from 'react';
import { createStore,Provider, applyMiddleware, combineReduxers, compose } from 'redux';
import thunkMiddleware from 'redux-thunk';
import createLogger from 'redux-logger';
import { AppRegistry } from 'react-native';
import { expect,assert } from 'chai';
import reducer from './app/reducers';
import AppContainer from './app/containers/AppContainer'
const loggerMiddleware = createLogger({ predicate: (getState,action) => __DEV__ });
function configureStore (initialState) {
const enhancer = compose(
applyMiddleware(
thunkMiddleware,
loggerMiddleware,
),
);
return createStore(reducer, initialState, enhancer);
}
const store = configureStore({});
const App =() => (
<Provider store={store}>
<AppContainer />
</Provider>
)
AppRegistry.registerComponent('Appetizing',() => App);
,这是我AppContainer.js文件:
import React, { Component } from 'react'
import ReactNative from 'react-native'
const {
View,
Text,
} = ReactNative
class AppContainer extends Component{
render(){
return <View>
<Text style={{marginTop: 20}}>
I am app container
</Text>
</View>
}
}
export default AppContainer
你试过从'.app/containers/AppContainer''导入{AppContainer}吗? – G0dsquad
@ G0dsquad是的,没有用。我得到了同样的错误。 – userfi
如果我包含组件并将其呈现在标准视图中,您的代码实际上对我来说工作得很好,例如home.js(而不是'index.android.js')。 – G0dsquad