Skip to content

Commit f4d654a

Browse files
committed
✨ make forceDesktop work
1 parent 36670f7 commit f4d654a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

client/utils/responsive.jsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import React from 'react';
2+
import { useSelector } from 'react-redux';
23
import MediaQuery from 'react-responsive';
34
import ResponsiveForm from '../modules/User/components/ResponsiveForm';
45

56
export const mobileEnabled = () => (window.process.env.MOBILE_ENABLED === true);
67

7-
88
/** createMobileFirst: Receives the store, and creates a function that chooses between two components,
99
* aimed at mobile and desktop resolutions, respectively.
1010
* The created function returns a Component (props => jsx)
1111
*/
12-
export const createMobileFirst = store => (MobileComponent, Fallback) => props => (
13-
<MediaQuery minWidth={770}>
14-
{matches => ((matches || (store && store.getState().editorAccessibility.forceDesktop) || (!mobileEnabled()))
15-
? <Fallback {...props} />
16-
: <MobileComponent {...props} />)}
17-
</MediaQuery>);
12+
export const createMobileFirst = store => (MobileComponent, Fallback) => (props) => {
13+
const { forceDesktop } = useSelector(state => state.editorAccessibility);
14+
return (
15+
<MediaQuery minWidth={770}>
16+
{matches => ((matches || (store && forceDesktop) || (!mobileEnabled()))
17+
? <Fallback {...props} />
18+
: <MobileComponent {...props} />)}
19+
</MediaQuery>
20+
);
21+
};
1822

1923
export const responsiveForm = DesktopComponent => props => (
2024
<ResponsiveForm>

0 commit comments

Comments
 (0)