@@ -5,17 +5,15 @@ import React, { Component } from 'react'
55import {
66 customPropTypes ,
77 eventStack ,
8- getElementType ,
98 getUnhandledProps ,
109 META ,
10+ withElementType ,
1111} from '../../lib'
1212
13- const ElementType = getElementType ( )
14-
1513/**
1614 * Responsive can control visibility of content.
1715 */
18- export default class Responsive extends Component {
16+ class Responsive extends Component {
1917 static propTypes = {
2018 /** An element type to render as (string or function). */
2119 as : customPropTypes . as ,
@@ -49,12 +47,6 @@ export default class Responsive extends Component {
4947 type : META . TYPES . ADDON ,
5048 }
5149
52- static onlyMobile = { minWidth : 320 , maxWidth : 767 }
53- static onlyTablet = { minWidth : 768 , maxWidth : 991 }
54- static onlyComputer = { minWidth : 992 }
55- static onlyLargeScreen = { minWidth : 1200 , maxWidth : 1919 }
56- static onlyWidescreen = { minWidth : 1920 }
57-
5850 constructor ( ...args ) {
5951 super ( ...args )
6052 this . state = { width : window . innerWidth }
@@ -112,10 +104,20 @@ export default class Responsive extends Component {
112104 // ----------------------------------------
113105
114106 render ( ) {
115- const { children } = this . props
107+ const { as : ElementType , children } = this . props
116108 const rest = getUnhandledProps ( Responsive , this . props )
117-
109+ console . error ( ElementType )
118110 if ( this . isVisible ( ) ) return < ElementType { ...rest } > { children } </ ElementType >
119111 return null
120112 }
121113}
114+
115+ const ResponsiveEnc = withElementType ( Responsive )
116+
117+ ResponsiveEnc . onlyMobile = { minWidth : 320 , maxWidth : 767 }
118+ ResponsiveEnc . onlyTablet = { minWidth : 768 , maxWidth : 991 }
119+ ResponsiveEnc . onlyComputer = { minWidth : 992 }
120+ ResponsiveEnc . onlyLargeScreen = { minWidth : 1200 , maxWidth : 1919 }
121+ ResponsiveEnc . onlyWidescreen = { minWidth : 1920 }
122+
123+ export default ResponsiveEnc
0 commit comments