Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

improve ts

Blue Mouse232f39df49cc
diff --git a/src/hoc/protected.tsx b/src/hoc/protected.tsx
index 0560ffd40..8391844ff 100644
--- a/src/hoc/protected.tsx
+++ b/src/hoc/protected.tsx
@@ -9,6 +9,10 @@ type AuthParamType = {
redirectPath: string
}
+type PropsType = {
+ [key: string]: any
+}
+
export const auth = {
authenticated: {
selector: (state: StateType) => state.auth.authenticated,
@@ -20,15 +24,15 @@ export const auth = {
},
}
-export const withAuthentication = (WrappedComponent: any, authParam: AuthParamType) => {
- const WithAuthentication = (params: any) => {
+export const withAuthentication = <P extends PropsType>(WrappedComponent: any, authParam: AuthParamType) => {
+ const WithAuthentication = (props: P) => {
const selector = useSelector(authParam.selector)
if (!selector) {
return <Redirect to={authParam.redirectPath} />
}
- return <WrappedComponent {...params} />
+ return <WrappedComponent {...props} />
}
return WithAuthentication