Skip to content

Instantly share code, notes, and snippets.

@jogilvyt
Last active June 22, 2022 13:26
Show Gist options
  • Save jogilvyt/f4699a1b26047d6a4e0e809d3314d25a to your computer and use it in GitHub Desktop.
Save jogilvyt/f4699a1b26047d6a4e0e809d3314d25a to your computer and use it in GitHub Desktop.

Revisions

  1. jogilvyt revised this gist Jun 22, 2022. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions to-do-solution.js
    Original file line number Diff line number Diff line change
    @@ -4,21 +4,23 @@ const ToDoList = ({ items }) => {
    return (
    <div>
    <ul>
    {items.length && items.map(item => <li key={item.id}>{item.text}</li>)}
    {items.length
    ? items.map((item) => <li key={item.id}>{item.text}</li>)
    : null}
    </ul>
    </div>
    );
    };

    const App = () => {
    const Apps = () => {
    return (
    <div>
    <h2>Today:</h2>
    <ToDoList
    items={[
    { id: 1, text: "Water the plants" },
    { id: 2, text: "Wash the car" },
    { id: 3, text: "Empty the bins" },
    { id: 3, text: "Empty the bins" }
    ]}
    />
    <h2>Tomorrow:</h2>
  2. jogilvyt created this gist Jun 22, 2022.
    30 changes: 30 additions & 0 deletions to-do-solution.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    import React from "react";

    const ToDoList = ({ items }) => {
    return (
    <div>
    <ul>
    {items.length && items.map(item => <li key={item.id}>{item.text}</li>)}
    </ul>
    </div>
    );
    };

    const App = () => {
    return (
    <div>
    <h2>Today:</h2>
    <ToDoList
    items={[
    { id: 1, text: "Water the plants" },
    { id: 2, text: "Wash the car" },
    { id: 3, text: "Empty the bins" },
    ]}
    />
    <h2>Tomorrow:</h2>
    <ToDoList items={[]} />
    </div>
    );
    };

    export default App;