Skip to content
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

[📖] Please do not override JS common stuff #6929

Open
Nefcanto opened this issue Oct 2, 2024 · 3 comments
Open

[📖] Please do not override JS common stuff #6929

Nefcanto opened this issue Oct 2, 2024 · 3 comments
Labels
COMMUNITY: good first issue Good for newcomers COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it COMP: docs Improvements or additions to documentation

Comments

@Nefcanto
Copy link

Nefcanto commented Oct 2, 2024

Suggestion

In the route loaders page it's specified that:

Route Loaders can only be declared inside the src/routes folder, in a layout.tsx or index.tsx file, and they MUST be exported.

Please don't override JS common practices. What if somebody wants to reuse a route loader across multiple index or layout files?

It's common in JS to break code into modules. Please don't prevent developers from defining a blogLoader in a separate file, and import/export it into /blog/index.jsx and /post/index.jsx files.

Please fix the aforementioned part of the documentation.

@Nefcanto Nefcanto added COMP: docs Improvements or additions to documentation STATUS-1: needs triage New issue which needs to be triaged labels Oct 2, 2024
@wmertens
Copy link
Member

wmertens commented Oct 2, 2024

Indeed you can re-export loaders. PRs for the docs always welcome 🤗

@wmertens wmertens added COMMUNITY: good first issue Good for newcomers COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it and removed STATUS-1: needs triage New issue which needs to be triaged labels Oct 2, 2024
@JerryWu1234
Copy link
Contributor

Could you please give me more clues how to fix it ?

@Nefcanto
Copy link
Author

Nefcanto commented Nov 7, 2024

@JerryWu1234, that message can be changed to something like this:

Please note that route loaders should be exported only from layouts or index files. But they can be declared in any valid way ES modules allow. To reuse a route loader across multiple layout or index files, define it in a separate file, export it, then import it in layout or index files and re-export it as a named export.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMMUNITY: good first issue Good for newcomers COMMUNITY: PR is welcomed We think it's a good feature to have but would love for the community to help with the PR for it COMP: docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants