Skip to content

Commit bd59537

Browse files
authored
Merge pull request #4 from fatehMohamed14/enhancement/upgrade-packages
Enhancement/upgrade packages and fix typing
2 parents 2673af8 + 5100db9 commit bd59537

4 files changed

Lines changed: 134 additions & 193 deletions

File tree

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
"react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0"
1919
},
2020
"devDependencies": {
21-
"@types/react": "^16.3.13",
21+
"@types/react": "^18.0.27",
2222
"babel-core": "^6.26.3",
2323
"babel-runtime": "^6.26.0",
2424
"clean-webpack-plugin": "^4.0.0",
25-
"css-loader": "^6.5.1",
26-
"react": "^16.12.0",
25+
"css-loader": "^6.7.3",
26+
"react": "^18.2.0",
2727
"style-loader": "^3.3.1",
28-
"ts-loader": "^9.2.6",
29-
"typescript": "^3.9.10",
30-
"webpack": "^5.65.0",
31-
"webpack-cli": "^4.9.1"
28+
"ts-loader": "^9.4.2",
29+
"typescript": "^4.9.4",
30+
"webpack": "^5.75.0",
31+
"webpack-cli": "^5.0.1"
3232
},
3333
"files": [
3434
"dist"
@@ -39,4 +39,3 @@
3939
"npm"
4040
]
4141
}
42-

src/PermifyProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useState } from "react";
1+
import React, { PropsWithChildren, useCallback, useState } from "react";
22

33
export interface UserPayload {
44
id: string,
@@ -11,9 +11,9 @@ import PermifyContext from "./PermifyContext";
1111

1212
const LOCAL_STORAGE_KEY_USER = "__permifyUser";
1313

14-
const PermifyProvider: React.FunctionComponent = ({
14+
const PermifyProvider = ({
1515
children
16-
}) => {
16+
}: PropsWithChildren) => {
1717
const [isLoading, setIsLoading] = useState<boolean>(false);
1818

1919
const updateUser = (newUser: UserPayload) => {

src/components/HasAccess.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { useEffect, useState, useContext } from 'react'
2+
import { useEffect, useState, useContext, PropsWithChildren } from 'react'
33

44
export interface UserPayload {
55
id: string,
@@ -13,17 +13,16 @@ export interface HasAccessProps {
1313
roles?: string[],
1414
permissions?: string[]
1515
isLoading?: React.ReactElement,
16-
renderAuthFailed?: React.ReactElement,
17-
children: React.ReactChild
16+
renderAuthFailed?: React.ReactElement
1817
}
1918

20-
const HasAccess: React.FunctionComponent<HasAccessProps> = ({
19+
const HasAccess = ({
2120
roles,
2221
permissions,
2322
isLoading,
2423
renderAuthFailed,
2524
children
26-
}) => {
25+
}: PropsWithChildren<HasAccessProps>) => {
2726
const [hasAccess, setHasAccess] = useState(false)
2827
const [checking, setChecking] = useState(false)
2928

@@ -59,9 +58,8 @@ const HasAccess: React.FunctionComponent<HasAccessProps> = ({
5958

6059
if (hasAccess) {
6160
return (
62-
<React.Fragment>
61+
// children is of type ReactNode which already includes ReactFragment
6362
{children}
64-
</React.Fragment>
6563
)
6664
}
6765

0 commit comments

Comments
 (0)