0.1.0 • Published 4 years ago

@bnt-ar/react-render-at v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

React Render At

Package Version

Installation

npm install @bnt-ar/react-render-at

Breakpoints

DeviceMinMax
Desktop1200pxInfinite
Laptop1024px1199px
Tablet768px1023px
Mobile0px767px

Usage

There are two ways you can use the package:

  • Via component
import React from 'react'
import {RenderAt} from 'react-render-at'  
  
class App = () => (  
    <h1>My App</h1>  
    <RenderAt desktop>  
        Content  
    </RenderAt>  
)  

Available props

PropTypeDefault
desktopbooleanno
laptopbooleanno
tabletbooleanno
mobilebooleanno
  • Via High Order Component
import React from 'react'
import RenderAtHOC from 'react-render-at'  
  
class App = props => (  
  <h1>My App</h1>  
  {
    props.isDesktop && <p>Content in Desktop</p>
  }
  {
    props.isLaptop && <p>Content in Laptop</p>
  }
  {
    props.isTablet && <p>Content in Tablet</p>
  }
  {
    props.isLaptop && <p>Content in Mobile</p>
  }
)

export default RenderAtHOC(App)