State for TodoApp was pretty straightforward. However, as you go on exploring other examples, the state becomes a little confusing. What is the best way to design state for a complex application?
In shopping cart example, the original result from API call was an array. But it later was converted into an object with keys as IDs. What is the significance of that? Is storing state as an array discouraged? I understand that the design of the state may vary according to the use-case. But is there any general rule of thumb to design state in order to manage it in a painless manner?
After 2 weeks of banging my head, I finally wrapped my head around how redux operates. However, designing the state is even mind-boggling.
If you point me to a pertaining article, that will also do.
Hi @mihir-harbinger! This question is answered in the Reducers section of the docs, check the note below "Designing the State Shape" section.
Hope that helps!
This qualifies as a usage question, and should really be asked on Stack Overflow instead.
That said, the Redux FAQ covers some of these topics, such as http://redux.js.org/docs/FAQ.html#organizing-state-nested-data . Dan's new "Idiomatic Redux" video series includes a lesson on "Normalizing the State Shape". I'm also hoping to write a recipe page shortly on "Structuring Reducers" - current discussion and plans are over at #1784 . The list of real Redux-based apps shows a number of real-world examples that could be informative. Finally, my list of links to React/Redux tutorials and articles has relevant articles as well.
Most helpful comment
This qualifies as a usage question, and should really be asked on Stack Overflow instead.
That said, the Redux FAQ covers some of these topics, such as http://redux.js.org/docs/FAQ.html#organizing-state-nested-data . Dan's new "Idiomatic Redux" video series includes a lesson on "Normalizing the State Shape". I'm also hoping to write a recipe page shortly on "Structuring Reducers" - current discussion and plans are over at #1784 . The list of real Redux-based apps shows a number of real-world examples that could be informative. Finally, my list of links to React/Redux tutorials and articles has relevant articles as well.