Split Layout Using Props
ReactJS
Hard
7 views
Problem Description
Create a TwoColumn layout component with left and right props.
Output Format
Render a React component.
Constraints
Use CSS grid for layout.
Official Solution
import React from 'react';
function TwoColumn({ left, right }) {
return (
<div style={{ display: 'grid', gridTemplateColumns: '220px 1fr', gap: 12, width: 720 }}>
<aside style={{ border: '1px solid #eee', borderRadius: 14, padding: 12 }}>{left}</aside>
<main style={{ border: '1px solid #eee', borderRadius: 14, padding: 12 }}>{right}</main>
</div>
);
}
export default function App() {
return (
<div style={{ padding: 16 }}>
<TwoColumn
left={<div><strong>Menu</strong><div style={{ color: '#555' }}>meetcode</div></div>}
right={<div><h1 style={{ marginTop: 0 }}>Topics</h1><p>Pick one and practice.</p></div>}
/>
</div>
);
}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!