score:0

what you need to do is called lift the state up (but in your case, is not the state, is a function)

what you could do is

function wrappercomponent(){
    const getmenudata = (action) => {...}

    return (
        <>
            <mainmenu getmenudata={getmenudata} />
            <home getmenudata={getmenudata} />
        </>
    )    
}

or

if getmenudata is a function that only depends on it's arguments, you could just put it in another file and import it to both components.

score:1

if the function doesn't use any state manipulation you can just take it out of the component and export it


Related Query

More Query from same tag