🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

react-delay-fallback

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-delay-fallback

React component to delay children rendering and show a fallback component while waiting

2.0.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

react-delay-fallback

version size download

React component to delay children rendering and show a fallback component while waiting

Installation

npm i react-delay-fallback

Compatibility

Compatible with React >=16.8.0
Compatible with Node >=8.0.0

Features

  • Extremely small: uses react hooks and will occupying less than 2kb in your final bundle
  • Safe unmounting: clears timers and listeners at unmounting

Other features

  • Runtime type checking with prop-types and static with typescript declaration files
  • Exhaustive doc comments
  • Tree shakable: exported with ESM modules
  • Tested with available coverage report

API

Index

Delay

Delay

import { Delay } from 'react-delay-fallback

Type: FunctionComponent

PropTypeDefaultUsage
timeout?number0Time in milliseconds for rendering
fallback?ReactNodeundefinedComponent to render instead of children while waiting
onRender?FunctionundefinedFunction to trigger on render

Usage examples

import { Delay } from 'react-delay-fallback';

function App() {
    const handleOnRender = () => window.alert('Callback invoked at rendering');

    return (
        <Delay
        timeout={5000}
        fallback={<span>Wait a moment...</span>} // <-- this will be rendered while page is loading
        onRender={handleOnRender}>
            <h1>This</h1>
            <p>Will appear after 5 seconds</p>
        </Delay>
    );
}

Dependencies

No dependencies

Peer dependencies

  • React: ^16.8.0
  • ReactDOM: ^15.6.2

License

MIT

Keywords

react

FAQs

Package last updated on 22 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts