react-guarded
Simple Guard component for react js.
Installation:
Install react-guarded via npm
npm install react-guarded --save
Integration
// index.js; Permissions;// Set permissions for current user Role;// set role for current user // app.component.js; <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