1.1.4 • Published 1 year ago

debounced-render v1.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Minified size   Version   Typescript   Build   License  

Easy to use wrapper react component to debounce the render of its children

Can be used in situtations like instant flickering of a loader if the loading process finishes very quickly

Examples:

import { DebouncedRender } from "debounced-render";

function MyComponent({ loading }) {
  return (
    // If the loading flag switches back to false before 200ms the <Loader /> component won't be rendered at all
    <DebouncedRender delay={200} renderCondition={loading}>
      <Loader />
    </DebouncedRender>
  );
}
import { DebouncedRender } from "debounced-render";

function MyComponent({ loading }) {
  return (
    // <Loader /> component will be rendered for at least 500ms after it is mounted.
    // Even if the loading flag switches to false immediately after child component is mounted
    <DebouncedRender 
        renderCondition={loading} 
        minDuration={500}>
      <Loader />
    </DebouncedRender>
  );
}

For smoother experience delay and minDuration should be used together

import { DebouncedRender } from "debounced-render";

function MyComponent({ loading }) {
  return (
    <DebouncedRender 
        renderCondition={loading} 
        // delay and minDuration can be used at the same time
        delay={500}
        minDuration={200}>
      <Loader />
    </DebouncedRender>
  );
}

Props

Prop NameDescription
renderConditionThe flag that decides if the children should be rendered
delay (Optional)Debouncing delay before mounting the children after the renderCondition flag is set to true(milliseconds)
minDuration (Optional)Minimum amount of time the children will stay mounted(milliseconds)
onRender (Optional)A callback function that will be called when the children is mounted
onHide (Optional)A callback function that will be called when the children is unmounted
1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago