New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-conditional-fallback

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-conditional-fallback

react-conditional-fallback

0.0.2
latest
Source
npm
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

react-conditional-fallback

npm downloads gzip size npm version PRs Welcome

Usage

Creates a component, provider, and controls for handling conditions in a react app.

import createConditionalFallback from 'react-conditional-fallback';

const optionalInitialValue = false;
const { Provider, useCondition, set, clear, ConditionalFallback } = createConditionalFallback(optionalInitialValue);

/*
 * `Provider` can hoist the state higher in the app, if omitted, the state exists at the level of the `ConditionalFallback`.
 * `useCondition` is a hook that returns the value of the condition
 * `set` sets the condition to `true`, note this does not need to be executed within the React context.
 * `clear` sets the condition to `false`, note this does not need to be executed within the React context.
 * `ConditionalFallback` operates similar to `React.Suspense` except that it renders the fallback when the condition is true (controlled via `set` and `clear`).
 * /

function App() {
  return (
    <ConditionalFallback fallback={<UnhappyPath />}>
      <HappyPath />
    </ConditionalFallback>
  );
}

This README was generated by anansi.

Keywords

anansi

FAQs

Package last updated on 10 May 2023

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