File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
+ import { useSelector } from 'react-redux' ;
2
3
import MediaQuery from 'react-responsive' ;
3
4
import ResponsiveForm from '../modules/User/components/ResponsiveForm' ;
4
5
5
6
export const mobileEnabled = ( ) => ( window . process . env . MOBILE_ENABLED === true ) ;
6
7
7
-
8
8
/** createMobileFirst: Receives the store, and creates a function that chooses between two components,
9
9
* aimed at mobile and desktop resolutions, respectively.
10
10
* The created function returns a Component (props => jsx)
11
11
*/
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
+ } ;
18
22
19
23
export const responsiveForm = DesktopComponent => props => (
20
24
< ResponsiveForm >
You can’t perform that action at this time.
0 commit comments