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

Comment component docs in Storybook cause the browser to hang #2003

Closed
tylersticka opened this issue Aug 4, 2022 · 8 comments · Fixed by #2048
Closed

Comment component docs in Storybook cause the browser to hang #2003

tylersticka opened this issue Aug 4, 2022 · 8 comments · Fixed by #2048
Assignees
Labels
🐛 bug Something isn't working 👷 dev 📚 documentation Improvements or additions to documentation

Comments

@tylersticka
Copy link
Member

If you view the Comment component in Storybook and attempt to switch to Docs view, the page completely tanks performance and appears to never resolve (at least in desktop Firefox as of this writing).

The story examples in this page are probably over-engineered (they predate Storybook Controls so it's been a while): If there isn't a quick fix, we may want to simplify things.

(My gut says this may have to do with the unique ID generation the stories are doing. If useEffect is running multiple times (see #1919) then maybe that's just constantly invalidating the stories and causing recompilation? But that's just a guess.)

@tylersticka tylersticka added 🐛 bug Something isn't working 📚 documentation Improvements or additions to documentation 👷 dev labels Aug 4, 2022
@calebeby calebeby self-assigned this Aug 23, 2022
@gerardo-rodriguez gerardo-rodriguez self-assigned this Sep 15, 2022
@gerardo-rodriguez
Copy link
Member

This one is a bit of a challenge to figure out. 😅

First, I started by commenting out the initCommentReplyForms(), but that didn't seem to do anything.

Next, I moved the useEffect() that calls initCommentReplyForms() into the decorators attribute on the <Meta>, something like:

<Meta
  title="Components/Comment"
  decorators={[
    (story) => {
      useEffect(() => {
        initCommentReplyForms();
      }, []);
      return story();
    },
  ]}
/>

But that didn't seem to do anything.

My next thing to try is simplifying the makeComment() function. I just reduced it to this:

export const makeComment = () => ({
  approved: true,
  comment_content: 'hello world',
});

And this seems to be making a difference! I don't understand why or what in makeComment() might be causing an issue, though. I'll keep digging. 🔍 👀

@calebeby
Copy link
Member

I remember running into this when I was trying to switch to vite. I think I figured out a way to work around this... if I remember right?

Here is the PR if you want to give it a shot and check if it is fixed there: #2012

I'd like to revisit that PR soon

@calebeby
Copy link
Member

If it is fixed there, I can look into why if you'd like.

@gerardo-rodriguez
Copy link
Member

Thanks, @calebeby, taking a look now!

@gerardo-rodriguez
Copy link
Member

@calebeby It does seem like it is fixed there!

If I start here: https://deploy-preview-2012--cloudfour-patterns.netlify.app/?path=/story/components-comment--single

Then switch over to the "Docs" tab, Firefox doesn't freeze up like it's doing now.

@gerardo-rodriguez
Copy link
Member

This is interesting, the initCommentReplyForms() function is being passed in as the 2nd argument of the template(). 🔍 👀

@calebeby
Copy link
Member

@gerardo-rodriguez do you have a few minutes to meet and check in about that PR? I can try to explain how that works and where I left it so we can decide what to do

@gerardo-rodriguez
Copy link
Member

@calebeby Sure! I have until about 11:30.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 👷 dev 📚 documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants