Last active
August 24, 2021 07:49
-
-
Save just-jeb/ce3d8610bb0465dd962736bd54cf55c2 to your computer and use it in GitHub Desktop.
Pure hook optimized
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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