@solidjs/router not working
Please can anyone help me out, i have been stuck for days... as i have this issues
15 Replies
It appears to you have your editor set to warn you when misspelled / unknown words are words. solidjs may not appear in the dictionary, but that makes it no less a valid package namespace, and
@solidjs/router
is the correct package name. This does not stop your package manager from installing it, or is simply the vscode extension warning that it doesn't know this wordthank you so much. but i seem to have a problem using the package in my code..
You should perhaps open a ticket explaining the issues you are facing
I will note, that solid-app-router is superseeded by
@solidjs/router
, there's no reason to have both in the same projectI have my index.tsx
my App.tsx
Plus nothing displays
i can't seem to see what is wrong... because in my console i get this error:
but where can i can open a ticket. i'm new here
What are the contents of Home.tsx?
import { render } from 'solid-js/web';
import { Router } from '@solidjs/router';
import App from './App';
import 'bootstrap/dist/css/bootstrap.min.css';
const root = document.getElementById('root');
if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
throw new Error(
'Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?',
);
}
render(() => <Router><App /></Router>, root!);
I meant to create a new thread here in #support. It's fine
Please enclose code blocks in triple back ticks for readability
This the App file. I'm asking about the Home file
import { Component } from 'solid-js';
const Home: Component = () => {
return (
<div>
<h2>Home</h2>
</div>
)
}
export default Home;
I think the issue is that the router requires Route components to be direct children
Try moving Router to inside the App component, wrapping the Route directly
Wow wow, you just saved me from a struggle of 3 days...
its working like magic
Thank you @foolswisdom you are wise
👍
Great