アプリの一部のメニューが展開されたときに静的にしたい固定位置のナビゲーションバーがあります。
問題は、両方のコンポーネントがアプリの階層構造で互いに遠く離れていることです。
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>
)
}