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 11import React from 'react' ;
2+ import { useSelector } from 'react-redux' ;
23import MediaQuery from 'react-responsive' ;
34import ResponsiveForm from '../modules/User/components/ResponsiveForm' ;
45
56export 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
1923export const responsiveForm = DesktopComponent => props => (
2024 < ResponsiveForm >
You can’t perform that action at this time.
0 commit comments