【发布时间】:2020-03-29 07:36:47
【问题描述】:
我有一个固定位置的导航栏,当应用程序中的某些菜单展开时,我想将其设为静态。
问题是两个组件在应用层次结构中彼此相距很远。
const Nav = () => {
const navRef = useRef(null);
return (
<nav
ref={navRef}
></nav>
);
}
const Menu = () => {
// I want to access the nav ref here to change its style when the menu expands
return (
<ul></ul>
)
}
【问题讨论】: