Skip to content

Commit

Permalink
Hookify Responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Jun 7, 2019
1 parent 7b3f4fe commit 900e160
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/ra-ui-materialui/src/layout/Responsive.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React from 'react';
import PropTypes from 'prop-types';
import withWidth from '@material-ui/core/withWidth';
import { useTheme } from '@material-ui/styles';
import useMediaQuery from '@material-ui/core/useMediaQuery';

export const Responsive = ({
xsmall,
small,
medium,
large,
width,
...rest
}) => {
export const Responsive = ({ xsmall, small, medium, large, ...rest }) => {
const theme = useTheme();
const width =
[...theme.breakpoints.keys].reverse().reduce((output, key) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const matches = useMediaQuery(theme.breakpoints.only(key));
return !output && matches ? key : output;
}, null) || 'xs';
let element;
switch (width) {
case 'xs':
Expand Down Expand Up @@ -59,7 +60,6 @@ Responsive.propTypes = {
small: PropTypes.element,
medium: PropTypes.element,
large: PropTypes.element,
width: PropTypes.string,
};

export default withWidth()(Responsive);
export default Responsive;

0 comments on commit 900e160

Please sign in to comment.