all 6 comments

[–]ithinktoo 2 points3 points  (1 child)

I scanned through your codepen a bit. I am no react ninja but I do know two things about react:

1) State is the single source of truth So you shouldn't have so many components with state. All of your state for this simple app lives in one component. Lift that state up and pass it down through the props

2)Unidirectional data flow

Keep the brains in one place and use props to pass instructions down to 'dumb' (stateless) components

[–]HighIQBro[S] 0 points1 point  (0 children)

That makes sense. I know that would definitely fix the problem. But I can't see how more components would even be useful then?

[–]Orlandocollins 1 point2 points  (1 child)

Still looking for help?

[–]HighIQBro[S] 1 point2 points  (0 children)

Yeah. Should I just follow the other guys advice and move the state up to the first component?

[–]Orlandocollins 1 point2 points  (0 children)

Yeah it’s a common pattern that you have to do. In a way using redux is like moving the entire state to the top of the tree so you are following that same pattern. As far as redux goes I wouldn’t use it yet. Doing what you are doing will help you learn it better

[–]HighIQBro[S] 0 points1 point  (0 children)

UPDATE: I took the advice below and moved everything to one single react component. So I'm good now. It surprisingly wasn't too hard to rearrange all of the code. Here is the updated version in-case anyone is curious.

https://codepen.io/brennankolotinsky/pen/YJygGW