项目作者: antoniocapelo

项目描述 :
Simple react wrapper for the pagevisibility.js package render props for better composability.
高级语言: JavaScript
项目地址: git://github.com/antoniocapelo/react-page-visibility-render-props.git


react-page-visibility-render-props

Simple react wrapper for the pagevisibility.js package, using render props for better composability.

NPM JavaScript Style Guide

TODO: Complete the readme.

Install

  1. npm install --save react-page-visibility-render-props

Usage

Just pass a function as a child of the <PageVisibility> component. This function should have a single parameter, which can be visible | hidden | prerender (check here for full description).

  1. import React, { Component } from 'react'
  2. import PageVisibility from 'react-page-visibility-render-props'
  3. class Example extends Component {
  4. render () {
  5. return (
  6. <PageVisibility>
  7. {(pageVisibilityState) => {
  8. return (
  9. <div>Page is { pageVisibilityState } so will act accordingly</div>
  10. )
  11. }}
  12. </PageVisibility>
  13. )
  14. }
  15. }

License

MIT © António Capelo