We are trying to include AOR (version 1.3.1) in an existing application. When we follow the documentation we are facing an error.
List.js:442 Uncaught TypeError: Cannot read property 'list' of undefined
at Function.mapStateToProps [as mapToProps] (List.js:442)
We also observed that there has been some change to both the documentation and code in the recent releases, not able to nail the issue.
If we use AOR(version 1.2.3) then it works. But in the code we have the following different while combiningReducers
// create a Redux app
const reducer = combineReducers({
admin: adminReducer([{name: 'CampaignDetails'}]),
locale: localeReducer(),
form: formReducer,
routing: routerReducer,
});
The code for App.js mostly taken from the documentation:
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
Yes, we are sorry about that. The current documentation is not yet up to date with the latest release. Please refer to this issue for more info until we update it:
https://github.com/marmelab/admin-on-rest/issues/1078
EDIT
From your error message, I assume you are reading from the state somewhere in a custom component ?
In this case, we unfortunately included a BC in the 1.3.0 release: the state has been reorganized. You can find more infos about in this issue
In a nutshell, instead of state.admin[resource]
, use state.admin.resources[resource]