re: React Hook: usePermissions VIEW POST


This looks helpful as React is now in Preview.

And would you add the link to the repo by chance?

You can show the repo using following 👇 syntax

{% github sergiodxa/react-use-permissions %}

, which will display the repo like this.

sergiodxa / react-use-permissions

React hook for Permissions API


React hook for Permissions API

Note: This is using the new React Hooks API Proposal which is subject to change until React 16.7 final.

You'll need to install react, react-dom, etc at ^16.7.0-alpha.0


yarn add react-use-permissions


import usePermissions from '../src';

const format = hasPermissions => {
  switch (hasPermissions) {
    // User has granted permissions
    case true: {
      return "Permissions granted";
    // User has denied permissions
    case false: {
      return "Permissions denied";
    // User will be prompted for permissions
    case null: {
      return "Asking for permissions";

function App() {
  const hasPermissions = usePermissions("geolocation");
  const content = format(hasPermissions);
  return <h1>{content}</h1>;

code of conduct - report abuse