TITLE string const as fallback for meta.title default export#593
TITLE string const as fallback for meta.title default export#593
TITLE string const as fallback for meta.title default export#593Conversation
… export, for story title Signed-off-by: Lu Nelson <[email protected]>
|
Signed-off-by: Lu Nelson <[email protected]>
|
Appreciate the effort but I am not a big fan of adding this:
I wonder if we could fork https://github.com/facebook/react/tree/main/packages/react-refresh instead to keep HMR working for the current API? |
|
Hey @tajo, thanks for your response and comments. I get that this might seem like a hack (it is); but given that Ladle already implements not-quite-standard CSFv3, I though it might be thinkable to offer a solution to something that is an acknowledged problem with CSF. The goal in any case, is just to have more control over the story title, (which is to say mainly the nesting pattern of the title), so users can maintain a structured story organization without disabling HMR. And in my opinion, HMR is not just a "small improvement": being able to refresh without losing state for example, is a big deal in dev efficiency (and I would guess that Ladle's faster DX is one of the reasons for choosing it over Storybook, no?) Anyway, if there's a better way of doing this, I'm all ears. To your points:
Certainly that's true.
The way I wrote it so far, it's only a fallback option. So the default export would take precedence.
This part I don't understand. Could you explain what you mean here? Are there other/better ways of doing what I'm trying to do? |
If you make a code edit in the |
Ah, OK thanks. Well, I can offer some other things I discovered (at least, working in Ladle 4.x), which are perhaps more sensible solutions to the question of specifying the story title (while maintaining fast-refresh)—although I don't know if these are officially features, or just incidental behaviours? Anyway:
What do you think about a PR for adding this information to the docs, instead of the PR I proposed here? It would be very relevant to developers who value the fast-refresh workflow. |
|
It's already documented: https://ladle.dev/docs/stories#navigation-and-routes |
|
Ah yes I see, the part about file names is documented, although not the part about function names. It's also not indicated anywhere that the meta object disables fast-refresh and this the file/function naming pattern is an alternate solution to setting the title property in meta. Are you not interested in a PR to add this information to the docs? I think it would help a lot of users |
|
Definitely happy to approve any docs improvements. |
Since the default export of a non-primitive value breaks react-refresh functionality in Vite, this PR proposes an alternative for providing a Story title that is react-refresh compatible:
Instead of this:
Do this: