Skip to content

Commit

Permalink
modify text
Browse files Browse the repository at this point in the history
  • Loading branch information
gelove committed Jul 2, 2019
1 parent 4da40b9 commit e061881
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
- [`useSessionStorage`](./docs/useSessionStorage.md) — manages a value in `sessionStorage`.
- [`useThrottle` and `useThrottleFn`](./docs/useThrottle.md) — throttles a function. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/side-effects-usethrottle--demo)
- [`useTitle`](./docs/useTitle.md) — sets title of the page.
- [`usePermission`](./docs/usePermission.md) — query permission from the user depends on the specific API.
<br/>
<br/>
- [**Lifecycles**](./docs/Lifecycles.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/usePermission.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `usePermission`

React UI hook that query permission status from the user depends on the specific AP.
React side-effect hook that query permission status from the user depends on the specific API.


## Usage
Expand Down
2 changes: 1 addition & 1 deletion src/__stories__/usePermission.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ const Demo = () => {
return <pre>{JSON.stringify(state, null, 2)}</pre>;
};

storiesOf('UI|usePermission', module)
storiesOf('Side effects|usePermission', module)
.add('Docs', () => <ShowDocs md={require('../../docs/usePermission.md')} />)
.add('Demo', () => <Demo />);
7 changes: 5 additions & 2 deletions src/usePermission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ type PermissionDesc =
| MidiPermissionDescriptor
| PushPermissionDescriptor;

type State = PermissionState | '';

const noop = () => {};

const usePermission = (permissionDesc: PermissionDesc): string => {
const [state, setState] = useState('');
const usePermission = (permissionDesc: PermissionDesc): State => {
let mounted = true;
let permissionStatus: PermissionStatus | null = null;

const [state, setState] = useState<State>('');

const onChange = () => {
if (mounted && permissionStatus) {
setState(permissionStatus.state);
Expand Down

0 comments on commit e061881

Please sign in to comment.