.container {
display: grid;
grid-template-columns: repeat(5, 1fr);
}
function App() {
const [ count, setCount ] = useState(0);
const onChange = e => setCount(Math.max(0, e.target.value | 0));
return (
<div>
<input type="number" value={count} onChange={onChange} />
<div className="container">
{Array.from(Array(count).keys(), n => <div className="item">{n}</div>)}
</div>
</div>
);
}