-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
feat(nav): Add initial SecondaryNav component #83687
base: master
Are you sure you want to change the base?
Conversation
const ref = useRef<HTMLDivElement>(null); | ||
const {setSecondaryNavEl} = useNavContext(); | ||
|
||
useEffect(() => { | ||
if (ref.current) { | ||
setSecondaryNavEl(ref.current); | ||
} | ||
}, [ref, setSecondaryNavEl]); | ||
|
||
return <SecondarySidebarWrapper ref={ref} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think refs trigger useEffects. You might be seeing the useMemo from the context trigger the useEffect at the right time. This will also set it to null on unmount
const ref = useRef<HTMLDivElement>(null); | |
const {setSecondaryNavEl} = useNavContext(); | |
useEffect(() => { | |
if (ref.current) { | |
setSecondaryNavEl(ref.current); | |
} | |
}, [ref, setSecondaryNavEl]); | |
return <SecondarySidebarWrapper ref={ref} />; | |
const {setSecondaryNavEl} = useNavContext(); | |
return <SecondarySidebarWrapper ref={setSecondaryNavEl} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good call, this is much better
SecondaryNav.Body = function SecondaryNavBody({children}: {children: ReactNode}) { | ||
return <Body>{children}</Body>; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding functions to a function object seems cursed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's javascript for ya
Bundle ReportChanges will increase total bundle size by 223.25kB (0.71%) ⬆️. This is within the configured threshold ✅ Detailed changes
|
Adds the visual components and a story that will be added to as more work is done