react-guarded
v1.0.9
Published
Simple guard component for react js.
Downloads
5
Maintainers
Readme
react-guarded
Simple Guard component for react js.
Installation:
Install react-guarded via npm
npm install react-guarded --save
Integration
// index.js
import {Permissions, Role} from 'react-guarded';
Permissions.insert(['ADD', 'UPDATE']);
// Set permissions for current user
Role.set('admin');
// set role for current user
// app.component.js
import {Guarded} from 'react-guarded';
<Guarded permissions={['UPDATE']} > click update ...</Guarded>
Properties (optional)
permissions
- [?string[]
]
Permissions array for Guarded section in application.
<Guarded permissions={['UPDATE', 'MODIFY']} > click update ...</Guarded>
Owner
- [?any - React Component
]
Guarded parent component.
Permissions array for Guarded section in application.
<Guarded Owner={MyComponent} componentprop1={'balabala'} componentprop2={'balabala'} permissions={['UPDATE', 'MODIFY']} > click update ...</Guarded>
oneOf
- [?boolean
]
If oneOf properties are enabled, the existence of one of the permissions list is sufficient.
<Guarded oneOf permissions={['UPDATE', 'MODIFY']} > click update ...</Guarded>
hasRole
- [?string[]
]
Has role properties list all of roles for guarded area.
<Guarded oneOf hasRole={['admin', 'user']} permissions={['UPDATE', 'MODIFY']} > click update ...</Guarded>
Supported
If you have ideas for more “How To” recipes that should be on this page, Issues