1.2.2 • Published 3 years ago

react-memo-debounce v1.2.2

Weekly downloads
34
License
ISC
Repository
github
Last release
3 years ago

react-memo-debounce

Description:

A function to prevent unnecessary render calls. Almost like React.memo, but by default we will deeply compare values with debounce effect. So we will avoid many unnecessary render calls. It can be useful when each render operation is doing some expensive calculation.

How to install

npm install react-memo-debounce

Examples

Here we will wait 1000ms and compare props values by our isDeepEqual function

Import React from 'react'
import memoDebounce from 'react-memo-debounce'

function SimpleComponent(props) {
  const { title, description } = props
  return (
    <div>
      <h1>{title}</h1>
      <p>{description}</p>
    </div>
  )
}

export default memoDebounce(SimpleComponent, { delay: 1_000 })

Here we will wait 500ms and compare props by own function

Import React from 'react'
import memoDebounce from 'react-memo-debounce'

function SimpleComponent(props) {
  const { title, description } = props
  return (
    <div>
      <h1>{title}</h1>
      <p>{description}</p>
    </div>
  )
}

const isEqual = (prevProps, nextProps) => prevProps.title === nextProps.title
export default memoDebounce(SimpleComponent, { delay: 500, isEqualFunction: isEqual })
1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago