1.3.1 • Published 2 years ago

@sakit-sa/react-authorize v1.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@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

NameTypeDefaultDescription
checkstring, array[]This value must be exist in permissions prop. this is can a string or strings as array.
childrenelement-Specifies a content that must be show, if you have a permission.
fallbackelement-If you have any permission, it shows instead of children prop.
isViceVersabooleanfalseSpecifies 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.
permissionKeystring|Specifies a localStorage's key. It gets permissions from localStorage.
permissionsarray[]List of permission as string. note: if permissionKey has a value, permissions are ineffective.

License

MIT Licensed. © Copyright Saeed Abdilar