-
-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation Clarification for useIsAuthenticated
Hook
#1647
Comments
@locotinocom it is still not working here is my code `import React, { PropsWithChildren } from 'react' export default AuthenticatedComponent` i used your code but it always true!!! |
Please try this instead: if (isAuthenticated()) {return children}return null}This should work!Regards Am 29.03.2024 um 23:29 schrieb Saji Zeer ***@***.***>:
it is still not working here is my code
`import React, { PropsWithChildren } from 'react'
import useIsAuthenticated from 'react-auth-kit/hooks/useIsAuthenticated'
const AuthenticatedComponent = ({ children }: PropsWithChildren) => {
const isAuthenticated = useIsAuthenticated()
if (isAuthenticated) {
return children
}
return null
}
export default AuthenticatedComponent`
i used your code but it always true!!!
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
@locotinocom I did that and it is not working. |
`import React, { PropsWithChildren } from 'react' export default AuthenticatedComponent` i have to reload the app |
@locotinocom ` return () => isAuthenticated; |
Problem Description
While implementing authentication in a React project using
react-auth-kit
, I encountered a discrepancy between the expected behavior (based on the documentation on Getting Started with AuthKit) and the actual behavior of the
useIsAuthenticated
hook.According to the current documentation, the
useIsAuthenticated
hook is expected to be used as follows:However, this implementation throws an error indicating that
isAuthenticated()
is not a function. Upon further inspection, it was discovered thatuseIsAuthenticated
directly returns a boolean value indicating the authentication status, rather than returning a function that when called, returns the authentication status.Suggested Documentation Update
To clarify the usage of
useIsAuthenticated
and prevent potential confusion for future users ofreact-auth-kit
, I propose the following update to the documentation:Change the example usage of
useIsAuthenticated
to reflect that it returns a boolean value directly:Additionally, it may be beneficial to add a note explaining that
useIsAuthenticated
does not need to be called as a function but is instead a boolean value representing the user's authentication status.Conclusion
Correcting this discrepancy in the documentation can improve the developer experience and help prevent similar confusion in the future. I appreciate the effort that has gone into creating
react-auth-kit
and hope this contribution helps enhance its utility for the developer community.The text was updated successfully, but these errors were encountered: