@sakit-sa/react-authorize

1.3.1 • Public • Published

@sakit-sa/react-authorize

This component helps to show an element, if you have a permission. It's based on React.

NPM JavaScript Style Guide

Live Playground

To run that demo on your own computer:

Getting Started

Install

npm install @sakit-sa/react-authorize

Usage

import React from 'react';
import Authozie from '@sakit-sa/react-authorize';

const App = () => (
    <Authozie
        check={"permission_1"}
        permissions={['permission_0', 'permission_1']}
    >
        The content
    </Authozie>
);

Props

Name Type Default Description
check string, array [] This value must be exist in permissions prop. this is can a string or strings as array.
children element - Specifies a content that must be show, if you have a permission.
fallback element - If you have any permission, it shows instead of children prop.
isViceVersa boolean false Specifies a boolean value. If the value is false, check prop must be exist in permissions prop and If the value is true, check prop must not be exist in permissions props and actually in this case, children are shown.
permissionKey string `` Specifies a localStorage's key. It gets permissions from localStorage.
permissions array [] List of permission as string. note: if permissionKey has a value, permissions are ineffective.

License

MIT Licensed. © Copyright Saeed Abdilar

Dependents (0)

Package Sidebar

Install

npm i @sakit-sa/react-authorize

Weekly Downloads

1

Version

1.3.1

License

MIT

Unpacked Size

16.9 kB

Total Files

6

Last publish

Collaborators

  • saeed.abdilar