Skip to content

Instantly share code, notes, and snippets.

@just-jeb
Last active August 24, 2021 07:49
Show Gist options
  • Select an option

  • Save just-jeb/ce3d8610bb0465dd962736bd54cf55c2 to your computer and use it in GitHub Desktop.

Select an option

Save just-jeb/ce3d8610bb0465dd962736bd54cf55c2 to your computer and use it in GitHub Desktop.
Pure hook optimized
import React, { useMemo } from 'react';
import { Permissions, usePermissions } from '@hooks/permissions';
const useIsPermitted = () => {
// usePermissions is another custom hook that returns an array of permissions
const permissions = usePermissions();
return useMemo(() => ({
isEditPermitted: permissions.includes(Permissions.EDIT_SITE_PERMISSION),
}), [permissions]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment