diff --git a/packages/ra-ui-materialui/src/layout/AppBar.js b/packages/ra-ui-materialui/src/layout/AppBar.js index c940e4c7e53..ed284b4f042 100644 --- a/packages/ra-ui-materialui/src/layout/AppBar.js +++ b/packages/ra-ui-materialui/src/layout/AppBar.js @@ -1,6 +1,6 @@ import React, { Children, cloneElement } from 'react'; import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; +import { useDispatch, useSelector } from 'react-redux'; import classNames from 'classnames'; import MuiAppBar from '@material-ui/core/AppBar'; import Toolbar from '@material-ui/core/Toolbar'; @@ -8,9 +8,8 @@ import IconButton from '@material-ui/core/IconButton'; import Typography from '@material-ui/core/Typography'; import { makeStyles } from '@material-ui/core/styles'; import MenuIcon from '@material-ui/icons/Menu'; -import withWidth from '@material-ui/core/withWidth'; -import compose from 'recompose/compose'; -import { toggleSidebar as toggleSidebarAction } from 'ra-core'; +import useMediaQuery from '@material-ui/core/useMediaQuery'; +import { toggleSidebar } from 'ra-core'; import LoadingIndicator from './LoadingIndicator'; import DefaultUserMenu from './UserMenu'; @@ -54,24 +53,31 @@ const AppBar = ({ logout, open, title, - toggleSidebar, userMenu, - width, ...rest }) => { const classes = useStyles({ classes: classesOverride }); + const dispatch = useDispatch(); + const locale = useSelector(state => state.i18n.locale); + const isXSmall = useMediaQuery(theme => theme.breakpoints.down('xs')); + return ( - + dispatch(toggleSidebar())} className={classNames(classes.menuButton)} > , }; -const enhance = compose( - connect( - state => ({ - locale: state.i18n.locale, // force redraw on locale change - }), - { - toggleSidebar: toggleSidebarAction, - } - ), - withWidth() -); - -export default enhance(AppBar); +export default AppBar;