14
23 Comments

I built a todo list app with React Hooks 😎

Hey!

To teach myself react hooks, I built a todo list app using React Hooks, and some CSS.

You can try it here.

It's the first web application I've built with React hooks, so I'd definitely appreciate any feedback on the open source Github repo.

on March 9, 2021
  1. 4

    useCaptainHook 🎉

    1. 1

      Is that a custom hook that is good for a todo list application?

      1. 3

        Haha no it's just pun reference to the guy from peter pan.

        But maybe it should be a package 😛

        1. 2

          Haha I even searched that package on Google to try to find the package lol.

          1. 2

            In JS world it's a fair assumption that anything exists lol

  2. 2

    Excellent job! It’s great that you’re happy to post your code in public.

    You’ve had some good feedback already and I don’t have anything to add, but I wanted to reply to say that you’re doing great! Keep it up!!

    1. 1

      Hey Dave,

      Thanks! I appreciate it:)

  3. 2

    Nice work Josh.

    One thing I wish I had learned earlier is the concept of normalized state.
    Instead of storing your tasks in an array, store them in an object.
    That way, reads/edits are fast and easy.

    e.g.

    tasks= {
      taskId1:  { title: "Here is a task", completed: true },
      taskId2:  { title: "Another task", completed: false },
      ...
    };
    

    Then getting a value is as easy as tasks[taskId].title

    Setting/editing values is easy too, you don't have to do any array manipulations.

    Since objects don't have order, you can have another array to keep track of order
    e.g.

    tasksArray= [taskId1, taskId2, ... ]
    

    Then producing the list is easy:

    tasksArray.map(taskId =>
    <div>
    {tasks[taskId].title}
    </div>
    );

    This is very useful once your state becomes larger and/or more complex.

    See: https://redux.js.org/recipes/structuring-reducers/normalizing-state-shape

    1. 1

      That's extremely helpful. Thank you!

  4. 2

    Hi Josh, nice project! :)

    1. 1

      Hey! Thanks :)

  5. 2

    Very good job, and really brave to share the source code. Adding the date and time for each task might be a big advantage, but I'm not sure if you would like to develop your product in that direction.

    1. 1

      Thank you! That's a good idea for a way to improve the product. I will give that a shot!

  6. 2

    Congrats! Will give it try for preparing our launch with paperless.io

    1. 1

      Great! Thank you, let me know how the launch goes.

  7. 2

    Nicely done, thanks for sharing!

    1. 1

      Thanks, appreciate it!

  8. 2

    Nice job! It takes some courage to post a source code, especially when you are learning something new.

    Keep going :)

  9. 2

    When I add a new item the number of tests to complete increments, but the item doesn't show in the list.

    UI is nice, I'd suggest making the 'complete' and 'X' buttons a bit nicer to match the rest of your design, check out Feather Icons for React - might be useful.

    1. 1

      It's because the container of the Tasks a max height, you just have to scroll down on top of the tasks and you will be able to see the other ones. I might improve this in the near future.

  10. 3

    This comment was deleted 4 years ago

    1. 1

      That's helpful! Thank you.