I would like to scroll to menu element in a page.
I have the menu component which is not a parent of components to which I would like to scroll.
I have found this post that describe a similar problem
Passing ref to a child We want the ref to be attached to a dom element, not to a react component. So when passing it to a child
component we can't name the prop ref.
const myRef = useRef(null) return <ChildComp refProp={myRef}></ChildComp> } ``` Then attach the ref prop to a dom element. ```jsx const ChildComp = (props) => { return <div ref={props.refProp} /> } ```
Here's my app structure
Menu component:
const MenuApp = () => {
    return (
        <div>
            <div className="desktop-menu">
                <div className="menu-item a-propos">
                    <p className='button'>Me découvrir</p>
                </div>
                <div className="menu-item competences">
                    <p className='button'>Compétences </p>
                </div>
                <div className="menu-item experiences">
                    <p className='button'>Experiences</p>
                </div>
                <div className="menu-item formation">
                    <p className='button'>Formation </p>
                </div>
            </div>
        </div>
    )
}
The parent is app component
 <div className="App">
  <div className="hero">
    <HeaderApp />
    <ApprochApp />
  </div>
  <Apropos />
  <Competences />
  <Experiences />
  <Formation />
  <Recom />
  <Contact />
  <Footer />
 </div >
I would like that mu menus scrolls to the react components in the main App component
So how can I passe the reference from the menu component to the app and use it in components to scroll ?