-
Notifications
You must be signed in to change notification settings - Fork 2
Storybook HMR not triggering refresh correctly #18
Comments
No, not missing anything. This happens to me, too, but I'm not sure why. I'll look into it though. |
@alexlafroscia I might be totally wrong, but i have a theory that the root of the problem is that the /shrug |
Hm! That's interesting. I think I remember reading somewhere that there's a way to make |
Related: skatejs/skatejs#564 |
If that's indeed the issue, I'm not sure about JSX and using a dynamic element name. Since the JSX can't use the constructor anymore in Skate 5, and thus has to use the actual name of the element, I'm not sure how we'd handle not manually setting the name of the component... |
The docs mention using |
@alexlafroscia 👋 So I played with this a little bit and 🔎 the issue + docs you mentioned.
As of right now, 5.x's define() is really simple, and it doesn't deal with name collisions: I don't have enough context to know if this should be in Skate or not, but for now I added a custom define function used by function define(Ctor) {
const registry = customElements;
const name = registry.get(Ctor.is) ? `${Ctor.is}-${uniqueId()}` : Ctor.is;
registry.define(name, Ctor);
return Ctor;
} And now I can get Storybook to update when I change my components, the drawback I see is that I'm registering a new element on every change, not sure about the impact of this since its just for dev + storybook. |
Ahh forgot to mention some really important things:
|
As I understood it, support for this was being dropped in Skate 5. Is that still the case @treshugart?
That's interesting. I'm not sure where Where are you calling |
In You could do something similar to this skatejs/skatejs#564 (comment) but its not not exactly how you want it, you would still need to invoke it :/ |
Hm, that's interesting. Kind of lets the importer decide if they want to auto- What do you think a good default behavior for the Yeoman generator would be? |
Correct.
Hmm, I think the generator should aim for simplicity, that is auto defining the element on import (so no changes to the current implementation). However at least in my use case having HMR is pretty useful, but I can't think of a solution right now that would solve for both cases. Feel free to close the issue. |
@alexlafroscia I had more time to play around with this and ended up needing the element to auto-define. What I ended up doing is having 2 files, one exporting the class of the Element and another one that includes it and defines it. I use the latter when exporting it as a library, but for my This way I can get storybook to update and have my elements auto-defined when requiring them in other apps. However this still relies on sing the class directly in JSX instead of the name. |
@deini if you want to send a PR I'm happy to review it. |
Just generated a component but when I make a change in my component the Storybook doesn't reload.
Looks like its getting the change but I don't see it reflected unless I refresh.
Am I missing something?
The text was updated successfully, but these errors were encountered: