我们正在尝试将AOR(版本1.3.1)包含在现有应用程序中。当我们按照documentation时,我们会遇到错误。
List.js:442 Uncaught TypeError: Cannot read property 'list' of undefined
at Function.mapStateToProps [as mapToProps] (List.js:442)
我们还观察到最近版本中的文档和代码都发生了一些变化,但无法解决问题。
如果我们使用AOR(版本1.2.3),那么它可以工作。但是在代码中,我们在组合Reducers
时有以下不同之处// create a Redux app
const reducer = combineReducers({
admin: adminReducer([{name: 'CampaignDetails'}]),
locale: localeReducer(),
form: formReducer,
routing: routerReducer,
});
App.js的代码主要取自文档:
import React from 'react';
import PropTypes from 'prop-types';
import { render } from 'react-dom';
// redux, react-router, redux-form, saga, and material-ui
// form the 'kernel' on which admin-on-rest runs
import { combineReducers, createStore, compose, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import createHistory from 'history/createHashHistory'
import { Switch, Route } from 'react-router-dom'
import { ConnectedRouter, routerReducer, routerMiddleware } from 'react-router-redux';
import { reducer as formReducer } from 'redux-form';
import createSagaMiddleware from 'redux-saga';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
// prebuilt admin-on-rest features
import {
adminReducer,
localeReducer,
crudSaga,
TranslationProvider
} from 'admin-on-rest';
import restClient from './restClient';
import GenericList from './alteui/components/genricComponents/GenricList';
// Customer
import CustomerEdit from './alteui/views/customer/customerEdit';
// your app labels
import messages from './i18n';
// create a Redux app
const reducer = combineReducers({
admin: adminReducer,
locale: localeReducer(),
form: formReducer,
routing: routerReducer,
});
const sagaMiddleware = createSagaMiddleware();
const history = createHistory();
const store = createStore(reducer, undefined, compose(
applyMiddleware(sagaMiddleware, routerMiddleware(history)),
window.devToolsExtension ? window.devToolsExtension() : f => f,
));
sagaMiddleware.run(crudSaga(restClient));
const App = () => (
<Provider store={store}>
<TranslationProvider messages={messages}>
<ConnectedRouter history={history}>
<MuiThemeProvider>
<Switch>
<Route exact path="/"
hasCreate render={
(routeProps) => <GenericList resource="CampaignDetails" {...routeProps} />
} />
</Switch>
</MuiThemeProvider>
</ConnectedRouter>
</TranslationProvider>
</Provider>
);
export default App
&#13;
答案 0 :(得分:1)
是的,我们很抱歉。当前文档尚未与最新版本保持同步。在我们更新之前,请参阅此问题以获取更多信息:
https://github.com/marmelab/admin-on-rest/issues/1078
修改强>
从您的错误消息中,我假设您正在从自定义组件中的某个位置读取数据?
在这种情况下,我们遗憾地在1.3.0版本中包含了BC:状态已经重组。您可以在此issue
中找到更多相关信息简而言之,请使用state.admin[resource]
state.admin.resources[resource]