React

by jasonmlutz

HTML

<div id="app"></div>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

li {
  margin: 8px 0;
}

h2 {
  font-weight: bold;
  margin-bottom: 15px;
}

.done {
  color: rgba(0, 0, 0, 0.3);
  text-decoration: line-through;
}

input {
  margin-right: 5px;
}

React

const App = () => {
  const data = [...Array(100).keys()];

  const renderTable = (data) => {
    const rows = [];
    for (let i = 0; i < data.length; i += 6) {
      rows.push(<tr key = {i}>{renderRow(data.slice(i, i + 6))}</tr>);
    }
    return rows;
  };

  const renderRow = (row) => {
    return row.map((element) => <td key={element}>{element}</td>);
  };

  return (
    <table>
      <thead>
        <tr>
          <th>Column 1</th>
          <th>Column 2</th>
          <th>Column 3</th>
          <th>Column 4</th>
          <th>Column 5</th>
          <th>Column 6</th>
        </tr>
      </thead>
      <tbody>{renderTable(data)}</tbody>
    </table>
  );
};

ReactDOM.render(<App />, document.querySelector("#app"))