diff --git a/package-lock.json b/package-lock.json index db2ea589..6efa13f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@propelauth/react", - "version": "1.2.7", + "version": "1.2.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@propelauth/react", - "version": "1.2.7", + "version": "1.2.9", "license": "MIT", "dependencies": { "@propelauth/javascript": "^1.2.3", @@ -41,8 +41,8 @@ "uuid": "^8.3.2" }, "peerDependencies": { - "react": "^16.8.0 || ^17.0.0", - "react-dom": "^16.8.0 || ^17.0.0" + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, "node_modules/@babel/cli": { diff --git a/src/withRequiredAuthInfo.tsx b/src/withRequiredAuthInfo.tsx index 7e4d65d3..b005aba7 100644 --- a/src/withRequiredAuthInfo.tsx +++ b/src/withRequiredAuthInfo.tsx @@ -2,9 +2,9 @@ import hoistNonReactStatics from "hoist-non-react-statics" import React, { useContext } from "react" import { Subtract } from "utility-types" import { AuthContext } from "./AuthContext" -import { getOrgHelper } from "./OrgHelper" import { RedirectToLogin } from "./useRedirectFunctions" import { WithLoggedInAuthInfoProps } from "./withAuthInfo" +import { withAuthInfo } from "./withAuthInfo" export interface WithRequiredAuthInfoArgs { displayWhileLoading?: React.ReactElement @@ -15,22 +15,12 @@ export function withRequiredAuthInfo
( Component: React.ComponentType
,
args?: WithRequiredAuthInfoArgs
): React.ComponentType ) => {
+ const WithRequiredAuthInfoWrapper = (props: Subtract ) => {
const context = useContext(AuthContext)
if (context === undefined) {
throw new Error("withRequiredAuthInfo must be used within an AuthProvider or RequiredAuthProvider")
}
- function displayLoading() {
- if (args && args.displayWhileLoading) {
- return args.displayWhileLoading
- } else {
- return (
}
}
- const { loading, authInfo, selectOrgId, userSelectedOrgId } = context
- if (loading) {
- return displayLoading()
- } else if (authInfo) {
- const orgHelper = getOrgHelper(authInfo.orgHelper, selectOrgId, userSelectedOrgId)
- const loggedInProps: P = {
- ...(props as P),
- accessToken: authInfo.accessToken,
- isLoggedIn: !!authInfo.accessToken,
- orgHelper: orgHelper,
- user: authInfo.user,
- }
- return