Replies: 2 comments 3 replies
-
I'm typically on team no-default-exports, but I actually think in this case they make the developer experience a bit nicer. I can name my routes whatever I'd like without having to re-export it as
Yes you might want to import it in a test file, but I'd almost always opt to just test the interactions on the page than write unit tests for the component itself. In any case, this seems like an outlier and not a good enough reason to change conventions.
Sure, but IMO that's no worse for the call-stack/dev tools than seeing So...I dunno. Default exports seem fine to me in this case, and just because some of us don't like that they exist in the first place doesn't seem like a compelling reason to ditch them. Because they do 😂 😭 I'd also just like to be really careful about introducing breaking changes without a solid reason to do so. Even with deprecation warnings and plenty of lead time, breaking changes suck. The more we introduce them, the more time developers have to spend dealing with this stuff than shipping products. Just not sure this change delivers the value to justify it. |
Beta Was this translation helpful? Give feedback.
-
For those transitioning from react-router to remix, it would be nice if the name of the “Component” export mirrored the react-router import * as someRoute from “./routes/some-route”
…
<Route {…someRoute} /> even better, have something do this for me from the fs 😄 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Proposal
Use
Component
named export instead ofexport default
in route files.Background
Using
export default
makes auto-import suggestions harder, and while you probably don't want, or should, import the route component if you're testing the component in Vitest/Jest you're going to need to import it.It also encourage exporting anonymous components.
Also all other route exports are named ones.
Use Case
API/Examples
And if you want to test this route component
Users could create a named component first and re-export it later
This could be either in v2 or in v1 by adding a fallback to
export default
.If the route doesn't have a
Component
export Remix could look up for adefault
export.If the route doesn't have Component or default, consider it a resource route.
Then on v2
export default
can be removed.A warning could also be added when
remix build
find out anexport default
to tell devs to switch toComponent
.Beta Was this translation helpful? Give feedback.
All reactions