Skip to content

Commit

Permalink
Merge pull request #2 from w01fgang/pass-validator-to-context
Browse files Browse the repository at this point in the history
🐛 pass validator to context
  • Loading branch information
w01fgang authored Jun 5, 2023
2 parents c02ae58 + f29d08c commit eb8a727
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "permission-gate",
"version": "1.0.3",
"version": "1.0.4",
"description": "A library for handling roles and permissions in large-scale React apps",
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
Expand Down
6 changes: 4 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {
useContext,
useMemo,
createContext,
cloneElement,
forwardRef,
Expand Down Expand Up @@ -30,9 +31,10 @@ type ConsumerProps = {
name: string,
};

export function PermissionGateProvider({ children, role, rulesMap }: ProviderProps): ReactElement {
export function PermissionGateProvider({ children, role, rulesMap, validator }: ProviderProps): ReactElement {
const value = useMemo(() => ({ role, rulesMap, validator }), [role, rulesMap, validator]);
return (
<RoleContext.Provider value={{ role, rulesMap }}>
<RoleContext.Provider value={value}>
{children}
</RoleContext.Provider>
)
Expand Down

0 comments on commit eb8a727

Please sign in to comment.