Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@steviecs/react-fallback

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@steviecs/react-fallback

A POC component library for rendering adaptive skeletons that adjust to the shape of your UI's layout while data is being fetched

  • 1.0.4
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source
Logo

react-fallback

Node.js CI Npm package version Npm package monthly downloads Maintenance GitHub license

A POC React component library for rendering skeleton states that automatically adapt to the shape of your UI layout while data is being fetched.

Demo

Try it live by reloading the sandbox browser: https://codesandbox.io/s/react-fallback-demo-b36dft?file=/src/App.tsx

Example

Installation

$ npm i @steviecs/react-fallback

Motivation

Because

return (
  <Fallback isLoading={data}>
    <div>
      <h1>{props.heading}</h1>
      <h2>{props.subheading}</h2>
      <p>S{props.body}</p>
    </div>
  </Fallback>
);

dunks on

  return (
    <>
      {isLoading ? (
        <div>
          <h1><Skeleton {...styles}/></h1>
          <h2><Skeleton {...styles}/></h2>
          <p><Skeleton {...styles}/></p>
        </div>
      ) : (
        <div>
          <h1>{props.heading}</h1>
          <h2>{props.subheading}</h2>
          <p>S{props.body}</p>
        </div>
      )}
    </>
  );

Props Reference

Fallback only

PropDescriptionDefault
isLoading: booleanA flag to determine if component-dependent data is being fetchedfalse
fallbackOnStaticContent?: boolean A flag to determine if static content should be skeleton-ized false

Implementation

At this time, react-fallback works by:

  • Consuming your JSX as a children inside of a <Fallback/> wrapper
  • Cloning the component tree
  • Iterating through child elements
  • Replacing children with a skeleton element that inherits all original style properties (except for the explicitly enforced background-color & animation)

Keywords

FAQs

Package last updated on 31 May 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc