Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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).