No Plugins; Monolithic
Publish your own packages to the world's most popular software ecosystem with npm Pro.Get started »

@mzvonar/defer-render-hoc

0.4.0 • Public • Published

defer-render-hoc

Forked from https://github.com/hanford/defer-render-hoc.

Added WaitingComponent argument, so you can display some kind of loader while waiting for render. Added option to disable functionality for SSR.

Defer expensive react rendering with rAF


Install

$ npm install @mzvonar/defer-render-hoc --save

Usage

import React, { Component } from 'react'
import deferRender from '@mzvonar/defer-render-hoc'
 
class RandomComp extends Component {
  ...
 
  render () {
    const { scroll } = this.props
 
    ...
  }
}
 
export default deferRender(RandomComp)

SSR

You can use third parameter isEnabled to disable this component. Either pass boolean value or a function that returns boolean.

export default deferRender(RandomComp, null, canUseDom())

Demo

See this CodeSandbox for a demo.

MIT © Jack Hanford

Install

npm i @mzvonar/defer-render-hoc

DownloadsWeekly Downloads

1

Version

0.4.0

License

MIT

Unpacked Size

13.2 kB

Total Files

15

Last publish

Collaborators

  • avatar