1.2.1 • Published 2 years ago

react-performance-hoc v1.2.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

React Performance Hoc

React high order component check how much does it take to render component

Installation

npm install react-performance-hoc

Simple Usage

import React from "react"
import withPerformance from "react-performance-hoc"
import Login from "./Login"

const App = () => {
  const PerformantLogin = withPerformance(Login)
  return (
    <div>
      <PerformantLogin/>
    </div>
  )
}

Parameters

Parameter NameDescriptionDefault
ComponentThe component you want to measure render time
identifierspecify identifier to easily catch which component it is"specify identifier"
errorTimeIf render time is more than this time, log with console.error200 (ms)
warnTimeIf render time is more than this time, log with console.warn100 (ms)
onPerformanceCapture()You can use the render time with callback as you wish, for example you can fetchIt prints the render time to the console according to the error and warn times

Usage with Params

import React from "react"
import withPerformance from "react-performance-hoc"
import Login from "./Login"

const App = () => {
  const onPerformanceCapture = (Component,identifier,renderedTime) => {
    fetch("url",{
      component: Component.name,
      identifier,
      time: renderedTime,
    })
  }
  const PerformantLogin = 
  withPerformance(
    Login,
    "login component", 
    1000,  
    100,    
    onPerformanceCapture
    )
  return (
    <div>
      <PerformantLogin/>
    </div>
  )
}
1.2.1

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.0

2 years ago