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

react-restricted

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-restricted

Permission-based view restrictions for React.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
278
increased by6850%
Maintainers
1
Weekly downloads
 
Created
Source

React Restricted

Build Status

Permission-based view restrictions for React.

Requirements

  • React >= 16.8.0

Install

yarn add react-restricted react react-dom

Usage

RestrictedView component

import { RestrictedProvider, RestrictedView } from "react-restricted";

function ViewExample() {
  return (
    <RestrictedProvider permissions={["somePermission"]}>
      <RestrictedView requiredPermission="somePermission">
        <SomeComponent />
      </RestrictedView>
    </RestrictedProvider>
  );
}

RestrictedContext

import { RestrictedProvider, RestrictedConsumer } from "react-restricted";

function ContextExample() {
  return (
    <RestrictedProvider permissions={["somePermission"]}>
      <RestrictedConsumer>
        {({ hasPermission }) =>
          hasPermission("somePermission") ? <SomeComponent /> : <SomeOtherComponent />
        }
      </RestrictedConsumer>
    </RestrictedProvider>
  );
}

useRestricted hook

import { useRestricted } from "react-restricted";

function HookExample() {
  const { hasPermission } = useRestricted();

  return hasPermission("somePermission")
    ? <SomeComponent>
    : <SomeOtherComponent />
}

Contributing

Please read our guidelines.

License

See LICENSE.

FAQs

Package last updated on 29 Mar 2019

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