I was watching a video about layout components and I saw that the author seemed to destructure the parameters but also assign it as a property in an object (as seen in Splitscreen.js)? I was wondering if anyone could help me understand what is going and why he chose to do this? Are there any advantages to doing so?
Splitscreen.js
export const Splitscreen = ({ left: Left, right: Right }) => {
return (
<Container>
<Pane>
<Left />
</Pane>
<Pane>
<Right />
</Pane>
</Container>
);
};
App.js
const LeftHandComponent = () => {
return <h1>Left</h1>;
};
const RightHandComponent = () => {
return <h1>Right</h1>;
};
function App() {
return <Splitscreen left={LeftHandComponent} right={RightHandComponent} />;
}
export default App;