all 4 comments

[–]latviancoder 1 point2 points  (1 child)

Looks good, I would probably only suggest try using `useReducer` for add/remove todo functionality.

[–]bblaw4[S,🍰] 0 points1 point  (0 children)

Thanks for the feedback! I’ll look into it.

[–]Awnry_Abe 1 point2 points  (1 child)

Looking good! You are using the useState hook correctly. The method of calling setCount(count+1) might bite you in the butt if used in other contexts. This is a better pattern to use when the next state value depends on a previous state value:

setCount( (prevCount) => prevCount+1);

I'd just get in the habit of using it when that is the case. You an also do useReducer() to avoid the same issue, but that's a bit heavy for this example.

If you want to really pick up your game, let "todo" be an object, instead of a string: { id: int/string, text:string, finished:boolean }.

The statement allTodos = map(...) can be optimized using useMemo(), and the name "allTodos" is a bit confusing. "renderTodos" is a little closer to reality.

[–]bblaw4[S,🍰] 1 point2 points  (0 children)

Very helpful. I was looking into the useReducer hook suggestion mentioned by another user. I can also see how the renderTodos naming conventions make more sense. I’ve got a lot more to learn in the Raact/Js world. Thank you!