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
Is Curi caching the routes? #77
Comments
const protectRoute = (route) => {
return () => {
if (!isLoggedIn()) {
return { redirectTo: { name: 'Login' } };
}
return { body: route };
}; Does that make sense? |
I think I should leave you alone with my trivial problems. Thank you so much! Also, do you have a donation link? I really love this project! |
No donations right now, but I appreciate the thought. If you know anyone else who might find Curi useful, I also appreciate sharing. I'm pretty close to finally releasing Side effects are being slightly re-worked to make them safer for React Suspense. Suspense won't release for a while, but I want to make sure that the transition for that is relatively seamless. |
That's good to know. I'll be looking out for it! |
Related to #74
Scenario:
User logs in and is directed to the next page (page requires authentication)
Problem:
My routes file contains the following function
which is placed on all routes where a user is not allowed unless authenticated. The issue is navigating programmatically. If I try to do
router.navigate({ name: 'Dashboard' });
, I am greeted by this error:Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
However, if I refresh the page everything loads fine and I am able to click links to other pages. As I've been debugging, I noticed that when Dashboard is called programmatically,
routes.js
is never hit again. So I tried placing a debugger on myReactDOM.hydrate
call and it results in this object being passed from the response:Notice the
redirectTo
object at the bottom. This means, according to theprotectRoute
function above,isLoggedIn()
is false which returns the redirect. At this point, I'm expecting the routes to be hit in order to determine if the user is logged in (which is true in this case).Any idea what this could be? Are the routes being "cached" in Curi?
The text was updated successfully, but these errors were encountered: