S
SolidJS•2mo ago
valerio.tsx

Renaming Index not working?

Hi! I just created a project with SolidStart starter and chose the tailwind with typescript template. I created a socials folder with a socials.tsx component (should render on /socials according to the docs (https://docs.solidjs.com/solid-start/building-your-application/routing#renaming-index) but it only renders under /socials/socials. The function that I'm exporting from socials.tsx looks like this:
export default function Index() {
return <h1>test</h1>;
}
export default function Index() {
return <h1>test</h1>;
}
I also tried renaming the function to Socials but didn't work, what am I missing? 🤔
7 Replies
Tommypop
Tommypop•2mo ago
You should rename socials.tsx to index.tsx I think Because an index.tsx file in a folder is used by the router as the route for that path If the filename isn't index.tsx, then the filename is used as the route suffix
valerio.tsx
valerio.tsx•2mo ago
yes, that works. But according to the docs:
By default, the component that is rendered for a route comes from the default export of the index.tsx file in each folder. However, this can make it difficult to find the correct index.tsx file when searching, since there will be multiple files with that name. To avoid this, you can rename the index.tsx file to the name of the folder it is in and it will be rendered as the default export for that route
Tommypop
Tommypop•2mo ago
Hmm, that might be a mistake in the docs. You should be able to bracket the put brackets round the name, (socials.tsx), if you don't want it named index
valerio.tsx
valerio.tsx•2mo ago
Yess, that works, thanks! You think I should open an issue on the solid-docs repo?
Luka
Luka•2mo ago
this doesnt work for me for me socials/index.ts only works did you get the layouts working?
Luka
Luka•2mo ago
GitHub
[Bug?]: rename the index.tsx file to the name of the folder always...
Duplicates I have searched the existing issues Latest version I have tested the latest version Current behavior 😯 As per documentation you should be able to rename the file to match the directory b...
Luka
Luka•2mo ago
I found two working options: Option 1: /socials/(anything_you_want).tsx works Options 2: If there is a file named index, this will take priority, i.e. /socials/index.tsx. Isn't option 1 supposed to be the layout feature? How to add a layout on socials and the children with option 1?
Want results from more Discord servers?
Add your server
More Posts
Getting Prisma TypeError in the browser console in a SolidStart app after doing build and start:The error: `TypeError: Failed to resolve module specifier ".prisma/client/index-browser". Relative I have a question when building npm create solid with-prisma template.In npm run dev, prisma with url="File:./dev.db" works fine, but when you run npm run build and startSolid and It's EcosystemWhat things do you feel like Solid Lacks compared to React in terms of Ecosystem?Getting random behavior from cache(), createAsync() and signalsThe "age" doesn't increase every time when I click the button. See: https://stackblitz.com/edit/gitSolidStart ver.1everytime I come to test solid, I'm met with issues out-of-the-box Also and Sorry to rant, but everyhaving separate layoutHello guys, I’m new to solid-start I have this inside my routes (app)/login/index.jsx I’m trying tModify dev server portI am working remotely and I keep getting this error during development: `can’t establish a connectioSOLVED: Trigger Side Effects on a Callbacks Dependency UpdatesI'm connecting a live feed to solid and currently trying to apply a filter. I filter the feed as it Destructuring functional props remove reactivity ?Non working example (direct destructuring) : ```jsx <Select placeholder="Select a running app" oCannot read properties of null (reading 'nextSibling') ERROR in a hello world simple Solidstart webi just added a route called docs to a brand new project in routes folder docs.mdx and inside it a te