Last active
May 25, 2021 06:23
-
-
Save francois-roget/139a3cffd41798e91e7bb76290fea6db to your computer and use it in GitHub Desktop.
This file contains 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 from 'react'; | |
import {Permission} from "../Types"; | |
type PermissionContextType = { | |
isAllowedTo: (permission: Permission) => boolean; | |
} | |
// Default behaviour for the Permission Provider Context | |
// i.e. if for whatever reason the consumer is used outside of a provider. | |
// The permission will not be granted unless a provider says otherwise | |
const defaultBehaviour: PermissionContextType = { | |
isAllowedTo: () => false | |
} | |
// Create the context | |
const PermissionContext = React.createContext<PermissionContextType>( defaultBehaviour); | |
export default PermissionContext; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment