Skip to content

Commit

Permalink
Merge pull request #66 from pundit-community/use-reactnode-type-inste…
Browse files Browse the repository at this point in the history
…ad-of-jsx-element

Replace deprecated JSX namespace with ReactNode type
  • Loading branch information
chrisalley authored Sep 14, 2023
2 parents d130ada + f0d1e24 commit 32f3d73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/react/pundit-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { JSX, ReactElement, useMemo } from 'react'
import React, { ReactNode, ReactElement, useMemo } from 'react'
import Policy from '../policy'

const PunditContext = React.createContext({ policy: new Policy(null, null) })
Expand All @@ -7,7 +7,7 @@ interface PunditProviderProps {
policy: Policy
user?: unknown
record?: unknown
children: JSX.Element | JSX.Element[] | null
children: ReactNode | ReactNode[] | null
}

export const usePundit = (): { policy: Policy } => {
Expand Down
5 changes: 3 additions & 2 deletions src/react/when.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ReactNode } from 'react'
import Policy from '../policy'
import { usePundit } from './pundit-provider'

interface WhenProps {
children: JSX.Element | null
children: ReactNode | null
can: string
policy?: Policy
user?: unknown
Expand All @@ -15,7 +16,7 @@ export default function When({
policy,
user,
record,
}: WhenProps): JSX.Element | null {
}: WhenProps): ReactNode | null {
const { policy: hookPolicy } = usePundit()
const paramPolicy = policy?.copy(user, record)
const canPerformAction = paramPolicy
Expand Down

0 comments on commit 32f3d73

Please sign in to comment.