Router brakes css

Code that works:
...(index.tsx)
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(() => <App />, root);
... (app.tsx)
function App() {
return (
<Router root={MainLayout}>

<Route path="/" component={TestComponent} />
<Route path="/cart" component={TestComponent} />
</Router>
);
}
function TestComponent(props: any){
let name = props.name ? props.name : 'Component'
console.log(name)
return (
<main class="mb-auto h-10 bg-green-500">{name}</main>

)
}
...
// Code that breaks
... index2.tsx

const elem: Element = document.getElementById("root")

render(() => (
<Router root={MainLayout}>
<Route path="/" component={MainLayout}>

<Route path="/cart" component={Cart} />
<Route path="/" component={TestComponent} />
<Route path="*404" component={()=>(<TestComponent name='not found'/>)} />
</Route>
</Router>
), elem);


function Cart() {
return (
<div class="p-4 grid">

<TestComponent name='cart'/>
<TestComponent name='cart'/>
<TestComponent name='cart'/>
<TestComponent name='cart'/>
<TestComponent name='cart'/>
</div>
)
}
...(index.tsx)
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(() => <App />, root);
... (app.tsx)
function App() {
return (
<Router root={MainLayout}>

<Route path="/" component={TestComponent} />
<Route path="/cart" component={TestComponent} />
</Router>
);
}
function TestComponent(props: any){
let name = props.name ? props.name : 'Component'
console.log(name)
return (
<main class="mb-auto h-10 bg-green-500">{name}</main>

)
}
...
// Code that breaks
... index2.tsx

const elem: Element = document.getElementById("root")

render(() => (
<Router root={MainLayout}>
<Route path="/" component={MainLayout}>

<Route path="/cart" component={Cart} />
<Route path="/" component={TestComponent} />
<Route path="*404" component={()=>(<TestComponent name='not found'/>)} />
</Route>
</Router>
), elem);


function Cart() {
return (
<div class="p-4 grid">

<TestComponent name='cart'/>
<TestComponent name='cart'/>
<TestComponent name='cart'/>
<TestComponent name='cart'/>
<TestComponent name='cart'/>
</div>
)
}
cc @Brendonovich
6 Replies
β˜Όπ•―π–†π–žπ–‘π–Žπ–Œπ–π–™β˜Ύ
I kind of feel that maybe it's tailwinds css that is unable to generate css for some reason as suspected that the devtools for some reason is not building the css in the second one I just did a tailwinds watch and linked the output css to index.html I don't really know how to trace the error / find why it's not working but sure if someone can help me then maybe this is a good first pr for us or me
Brendonovich
Brendonovichβ€’4mo ago
hmm nothing seems off there, can you reproduce the problem in stackblitz?
β˜Όπ•―π–†π–žπ–‘π–Žπ–Œπ–π–™β˜Ύ
alright it takes it's pretty time lol here https://stackblitz.com/edit/daisyui-solidjs-ppdn6e?file=src%2Findex.tsx so in the index.html comment out the stylesheet and you would see what I mean
Brendonovich
Brendonovichβ€’4mo ago
you're not importing index.css anywhere
β˜Όπ•―π–†π–žπ–‘π–Žπ–Œπ–π–™β˜Ύ
do I need to? πŸ‘€ amI dumb Thanks!!!
Want results from more Discord servers?
Add your server
More Posts
createShortcut callbacks fire even if a textinput has focusI'm making a todo app which has vim motions for navigation. When I hit 'j' or 'k' i'd like these keyRemoving element from store array doesn't remove rendered itemsHi, i need help with this. I have a store that is shared in a context with some helper functions. <Index> with storesHello there, I'm building an application where I have a store defined in a separate non-component fiCan't find replace attribute on <Navigate />This is basically my code, I am trying to check if the user is authenticated, if not then redirect tSolid-CLI won't create any projectWhen creating using `node` (either via `npx` or `bunx`) the CLI fails simply stating 'something wentcreateEffect is reactive, JSX isn't``` export const SavedLineView = (props: { loading: Accessor<boolean> }) => { createEffect(() => {Restricte route by user role, possibly a middleware?Hello, I would appreciate some assistance from more experienced web developers, if possible. My issNavigating with A from and to dynamic route doesn't re-render.I have a dynamic route `routes/post/[postid].tsx`. Within this route I have (simplified) ```tsx consIs it possible to get createAsync to revaluate/ refetch data like createResource?I see the example [here](https://github.com/solidjs/solid-router?tab=readme-ov-file#createasync) but[solved] Can't use `@solidjs/router` in external package for SolidStartI'm trying to write a library for my SolidStart project & need to use the `A` component exported fro