Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Change routing state key from routing to router #2553

Merged
merged 1 commit into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/CustomApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Fortunately, the `<Admin>` component detects when it's used inside an existing R

Beware that you need to know about [redux](http://redux.js.org/), [react-router](https://github.com/reactjs/react-router), and [redux-saga](https://github.com/yelouafi/redux-saga) to go further.

React-admin requires that the redux state contains at least 4 reducers: `admin`, `i18n`, `form`, and `routing`. You can add more, or replace some of them with your own, but you can't remove or rename them. As it relies on redux-form, react-router, and redux-saga, react-admin also expects the store to use their middlewares.
React-admin requires that the redux state contains at least 4 reducers: `admin`, `i18n`, `form`, and `router`. You can add more, or replace some of them with your own, but you can't remove or rename them. As it relies on redux-form, react-router, and redux-saga, react-admin also expects the store to use their middlewares.

Here is the default store creation for react-admin:

Expand Down Expand Up @@ -44,7 +44,7 @@ export default ({
admin: adminReducer,
i18n: i18nReducer(locale, i18nProvider(locale)),
form: formReducer,
routing: routerReducer,
router: routerReducer,
{ /* add your own reducers here */ },
});
const resettableAppReducer = (state, action) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-core/src/reducer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default (customReducers, locale, messages) =>
admin,
i18n: i18nReducer(locale, messages),
form: formReducer,
routing: routerReducer,
router: routerReducer,
...customReducers,
});

Expand Down
4 changes: 2 additions & 2 deletions packages/ra-core/src/sideEffect/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import {
import { FETCH_ERROR } from '../actions/fetchActions';
import { AUTH_LOGIN, AUTH_CHECK, AUTH_ERROR, AUTH_LOGOUT } from '../auth';
const nextPathnameSelector = state => {
const locationState = state.routing.location.state;
const locationState = state.router.location.state;
return locationState && locationState.nextPathname;
};

const currentPathnameSelector = state => state.routing.location;
const currentPathnameSelector = state => state.router.location;

export default authProvider => {
if (!authProvider) return () => null;
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/layout/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Menu.defaultProps = {
const mapStateToProps = state => ({
open: state.admin.ui.sidebarOpen,
resources: getResources(state),
pathname: state.routing.location.pathname, // used to force redraw on navigation
pathname: state.router.location.pathname, // used to force redraw on navigation
});

const enhance = compose(
Expand Down