Skip to content

Commit 2dcf64f

Browse files
authored
Simplify Grid Component
1 parent e5203c4 commit 2dcf64f

1 file changed

Lines changed: 6 additions & 12 deletions

File tree

src/components/Grid/index.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
import React, { Component } from 'react'
1+
import React from 'react'
22
import PropTypes from 'prop-types'
33
import './style.css'
44

5-
export default class Grid extends Component {
6-
Circles = () => {
7-
let div = []
8-
for (let index = 0; index < 9; index++) {
9-
div.push(<div key={index} style={{ background: `${this.props.color}` }}></div>)
10-
}
11-
return div;
12-
}
5+
export default function Grid({ color }) {
6+
const circles = [...Array(9)].map((_, index) => (
7+
<div key={index} style={{ background: `${color}` }} />
8+
));
139

14-
render() {
15-
return <div className="lds-grid">{this.Circles()}</div>
16-
}
10+
return <div className="lds-grid">{circles}</div>;
1711
}
1812

1913
Grid.propTypes = {

0 commit comments

Comments
 (0)