The React example is overly complicated, why track the new note title/description in App? You can keep addNote and have it take a note argument that the AddNote component can create. NotesList should own the notes list as well. Tracking everything in App and passing it down is the opposite of what hooks are meant to do.
I think you are correct here. I'm a little puzzled as to how I didn't think this through better at any point, because this is how I often structure similar apps, but overall I think your method makes more sense. I will probably make the simplifications you suggested and then edit this or write a follow-up detailing the reasoning. I think the only real reason I ever started using hooks this way would be because I learned them just by using them, so I guess it just made sense when I was first building apps with hooks, and it stuck with me without me ever really thinking about it.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The React example is overly complicated, why track the new note title/description in
App
? You can keepaddNote
and have it take anote
argument that theAddNote
component can create.NotesList
should own thenotes
list as well. Tracking everything inApp
and passing it down is the opposite of what hooks are meant to do.I think you are correct here. I'm a little puzzled as to how I didn't think this through better at any point, because this is how I often structure similar apps, but overall I think your method makes more sense. I will probably make the simplifications you suggested and then edit this or write a follow-up detailing the reasoning. I think the only real reason I ever started using hooks this way would be because I learned them just by using them, so I guess it just made sense when I was first building apps with hooks, and it stuck with me without me ever really thinking about it.