Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crisu83/react-restricted
Permission-based view restrictions for React.
https://github.com/crisu83/react-restricted
Last synced: 13 days ago
JSON representation
Permission-based view restrictions for React.
- Host: GitHub
- URL: https://github.com/crisu83/react-restricted
- Owner: crisu83
- License: mit
- Created: 2019-03-14T09:29:08.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-29T18:22:00.000Z (almost 6 years ago)
- Last Synced: 2024-10-30T00:40:04.646Z (3 months ago)
- Language: TypeScript
- Size: 240 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# React Restricted
[![Build Status](https://travis-ci.com/crisu83/react-restricted.svg?branch=master)](https://travis-ci.com/crisu83/react-restricted)
Permission-based view restrictions for React.
## Requirements
- React >= 16.8.0
## Install
```sh
yarn add react-restricted react react-dom
```## Usage
### RestrictedView component
```ts
import { RestrictedProvider, RestrictedView } from "react-restricted";function ViewExample() {
return (
);
}
```### RestrictedContext
```ts
import { RestrictedProvider, RestrictedConsumer } from "react-restricted";function ContextExample() {
return (
{({ hasPermission }) =>
hasPermission("somePermission") ? :
}
);
}
```### useRestricted hook
```ts
import { useRestricted } from "react-restricted";function HookExample() {
const { hasPermission } = useRestricted();return hasPermission("somePermission")
?
:
}
```## Contributing
Please read our [guidelines](.github/CONTRIBUTING.md).
## License
See [LICENSE](LICENSE).