SolidJSS
SolidJSโ€ข2y agoโ€ข
6 replies
tom1sl

Import error with Outlet

This is the code I apply to my routes to protect them from users who are not logged in, and I get this error in the browser console, I don't understand why I get this error if I followed the documentation.
import { Outlet, useNavigate } from "@solidjs/router";

export default function ProtectedRoute({
    canActivate,
    redirectPath = "/auth/login",
}) {
    const navigate = useNavigate();
    if (!canActivate) {
        navigate(redirectPath, { replace: true });
        return null;
    }

    return <Outlet />;
}

  Uncaught SyntaxError: The requested module '/_build/node_modules/@solidjs/router/dist/index.jsx' does not provide an export named 'Outlet' (at CheckAuth.jsx:1:10)

This is mi app.jsx
 export default function App() {
    return (
        <Router
            root={(props) => (
                <>
                    <div>
                        <Suspense>{props.children}</Suspense>
                    </div>
                </>
            )}
        >
            <Route element={<ProtectedRoute canActivate={true}/>}>
                <FileRoutes path="/" element={<Home />} />
            </Route>
            <FileRoutes path="/auth/login" element={<Login />} />
        </Router>
    );
} 
Was this page helpful?