-
Notifications
You must be signed in to change notification settings - Fork 9
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
[BUG] Authentication Loading State Issue with Vite #1009
Comments
Hey @nack43 thanks for the detailed explanation. In any way, the isLoading of auth state should be changed correctly, so I will check if there is an issue or suggest how to use it better. |
@rotemzif1 Thanks for your quick reply!
Yes, that would be what I want 👍
Thanks. |
Great then this is an example of using a custom loader :) @nack43
|
@rotemzif1 Thanks! I will try it this weekend. |
Thanks for your recommendations. I tried it, and it works. Here is my working code. const Provider = () => {
const [loading, setLoading] = React.useState(false);
return (
<div>
<FronteggProvider
customLoader={setLoading}
contextOptions={contextOptions}
authOptions={authOptions}
>
<App />
</FronteggProvider>
{loading && <div>loading</div>}
</div>
);
};
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<Provider />
</React.StrictMode>
); However, I've still encountered an issue. Even though I understand that the isLoading state within the Do you have any update on the situation regarding the potential bug in isLoading? If I have anything I can help, let me know. Thanks. |
@nack43 yes you are correct the isLoading state should be up to date and currently, it doesn't. We are working on a fix that will be published soon. What is your use case? would be happy to hear in order to verify it will work for you. |
@nack43 hey we have just released a new version with the fix for is Loading, you should now have the proper behaviour, by adding a new flag to the FronteggProvider -
can you please give it a try and let me know how it goes? |
@rotemzif1 |
I ended up creating this function to wrap my app: const TriggerWhenMounted = ({
children,
onMounted,
}: {
children: React.ReactNode;
onMounted: () => void;
}) => {
useEffect(() => {
onMounted();
}, [onMounted]);
return children;
}; and this is the app: function AppWithFrontegg() {
const [loading, setLoading] = useState(true);
return (
<>
{loading && <>loading</>}
<FronteggProvider
contextOptions={contextOptions}
authOptions={authOptions}
hostedLoginBox={true}
customLoader={true}
>
<TriggerWhenMounted onMounted={() => setLoading(false)}>
<App />
</TriggerWhenMounted>
</FronteggProvider>
</>
);
} |
Describe the bug
I'm currently developing a sample app with Frontendegg's authentication, utilizing the React integration guide. However, I am using Vite instead of Create React App (CRA) for this project.
The authentication process works as expected, but I encountered an issue when trying to display a loading component during this process. It seems that the
isLoading
state fromuseAuth()
consistently returnsfalse
.I discovered the
isLoading
property by inspecting the return type ofuseAuth()
. However, I found no mention of it in the existing documentation.This leads me to two questions:
isLoading
property?To Reproduce
Steps to reproduce the behavior:
const { user, isAuthenticated } = useAuth()
withconst { user, isAuthenticated, isLoading } = useAuth()
isLoading
istrue
e.g.if (isLoading) return <div>Loading...</div>
Expected behavior
I expect the 'isLoading' state to consistently return 'true' during the entire authentication process.
Screenshots
n/a
Additional context
I am using
Vite: 4.4.5
React: 18.2.0
@frontegg/react: 5.0.46
Feel free to ask me anything if you guys need more information. Thanks.
The text was updated successfully, but these errors were encountered: