-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix useEffect() in sky nav #1918
Conversation
|
✅ Deploy Preview for cloudfour-patterns ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Can you create an issue for the broader problem?
It's not important for those to continue to work. Maybe we should remove them if we know they're broken? |
✅ #1919
Remove all the prototypes which have the sky nav? Or remove the sky nav JS from those? I'm fine with either. Should that be in this PR or another? |
Either one. (Both questions.) |
@tylersticka I removed all the prototypes which call |
Closes #1909
The useEffect was being called multiple times, where it was before. I don't think it should have been placed where it was, because that is not in the top-level of a component, which is the only place where hooks are allowed.
It seems like Storybook made a change where story components now get rendered multiple times. Because of our placement of useEffect, the sky nav JS gets initialized twice. This caused it to expand and retract immediately when you click the menu button.
I changed the useEffect to be called in a decorator which I think is actually a component, so it should be OK to use useEffect there.
This problem exists in other components too. I can go through them and fix them if there are any others where the multiple-initialization of JS is causing a problem, but I figure that is not a launch blocker since for most of them it seems to not matter.
@tylersticka the sky nav JS in the prototypes that I added in #1503 is broken also, but I think for a different reason. I didn't look into fixing that since I'm not sure if it's important that those continue to work since we've implemented the production version now. Let me know if you want me to fix those!
https://deploy-preview-1918--cloudfour-patterns.netlify.app/?path=/story/components-sky-nav--dark