Can anyone please help me understand what is going on here in some code I need to refactor.
I have a component which looks pretty ordinary such as this:
export default class MyContainer extends PureComponent {
//props
//state
//render()
//etc.
}
This is then passed in as props to another component like this:
export class ParentContainer
render() {
return (
<div>
<Tabs
home={MyContainer}
/>
</div>
);
}
}
but what's got me confused is inside Tabs, it requires a function.
export default class Tabs extends PureComponent {
static propTypes = {
home: func.isRequired,
}
}
This raises many questions for me:
What does this home={MyContainer} do? Just instantiate a component inline with all default props maybe? I haven't seen that syntax before. And why is this component acting as a function. Is there something going on behind the scenes like react is implicitly converting the component to the render() function perhaps?
If I try instantiate it in the 'normal' way so that I can add some new props i.e. {<MyContainer />} I get a runtime error saying that Tabs is expecting a function? Should I just change the Tabs to expect an object to get this working?