I'm trying to understand this (radically simplified for purposes of asking this question) bit of code from Wordpress:
function MyFooContainer( {
        attr1,
        attr2,
        attr3,
        someVar
} ) {
        // do some stuff
        
        return (
                <>  
                    // some components
                </>
        );
}
const MyFooWrapper = withDispatch( (dispatch, ownProps, registry) => ( {
                // a bunch of code doing stuff, but no returns
        })
)( MyFooContainer );
 
const MyExportedFunction = (props) => {
        const { someVar } = props;
        const myTest = true;
        const Component = myTest
                ? MyFooWrapper
                : SomethingElse;
        return <Component { ...props } />
};
export default MyExportedFunction;
The way I understand things (which is probably poorly, as I'm new to both JS and React), someone calls MyExportedFunction with a bunch of parameters. One of those gets explicitly pulled out into someVar, by name. All of them get passed to Component as individual arguments (because of the ellipsis expansion). Component because of the way the test is set up, is just MyFooWrapper, which takes three arguments in order, so ... the first three props had better map to dispatch, ownProps, and registry? After that, I was really confused, but I guess base on this question that
const myFunction = withDispatch((args) => { })(MyFooContainer);
is an IIFE and MyFooContaner is passed as an argument to the withDispatch? But where did MyFooContainer get its arguments?
While we're here, why is MyFooContainer explicitly defined as a function, whereas the others are assigned as const? And last but not least, where does its return go? Who is catching that?
